Fast and Slow Pointer
public int fn(ListNode head) { ListNode slow = head; ListNode fast = head; int ans = 0;
while (fast != null && fast.next != null) { // TODO: logic slow = slow.next; fast = fast.next.next; }
return ans;}Reverse Linked List
public ListNode fn(ListNode head) { ListNode curr = head; ListNode prev = null;
while (curr != null) { ListNode nextNode = curr.next; curr.next = prev; prev = curr; curr = nextNode; }
return prev;}