Linked List Visualizer
Pointer Reversal
Trace prev, current, and next pointers as each node rewires its next reference to reverse the list in place.
O(n) time / O(1) space
Time
O(n)
Space
O(1)
Step Note
Create a demo cycle by pointing the tail back near the head.
function hasCycle(head: ListNode | null) {
let slow = head
let fast = head
while (fast !== null && fast.next !== null) {
slow = slow.next
fast = fast.next.next
if (slow === fast) return true
}
return false
}