Linked List
Notes and typical questions for linked list related problems
Notes
ListNode slow = head; ListNode fast = head; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; } // If the length of the list is even, slow points to 1st node of 2nd half of the list here // If the length of the list is odd, slow points to the exact mid node of the list hereListNode dummyHead = new ListNode(0); dummyHead.next = head; ListNode slow = dummyHead; ListNode fast = dummyHead; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; } // If the length of the list is even, slow points to the last node of 1st half of the list here // If the length of the list is odd, slow points to the exact mid node of the list here
Typical Questions (18)
Other Linked List questions (4)
Linked List Circle (2)
Linked List Manipulation (4)
Reverse Linked List (4)
Remove List Node (4)
Last updated
