public static SitesListNode reverseIteratively(SitesListNode head){
return doReverseIteratively(null, head);
}
private static SitesListNode doReverseIteratively(SitesListNode x, SitesListNode first) {
while (first != null) {
SitesListNode second = first.next;
first.next = x;
x = first;
if (second == null) {
break;
} else {
first = second;
}
}
return first;
}
public static SitesListNode reverseIteratively(SitesListNode head){
return doReverseIteratively(null, head);
}