dsa2 min read
Linked List Cycle II — Floyd's Cycle Start Detection
Find the node where a cycle begins using Floyd's algorithm: detect meeting point, then reset one pointer to head.
Read →
1575 articles
Find the node where a cycle begins using Floyd's algorithm: detect meeting point, then reset one pointer to head.
Find the duplicate in an array of n+1 integers in O(1) space by treating indices as a linked list with Floyd's cycle detection.
Find the next greater value for each node in a linked list using a monotonic decreasing stack of indices.
Implement a doubly linked list with sentinel head and tail nodes for clean O(1) insertions and deletions.
Swap the kth node from the front with the kth node from the end by finding both with two pointers.