LeetCode 141 - Linked List Cycle
Detect a cycle in a linked list — from a hash set that tracks visited nodes to Floyd's two-pointer tortoise-and-hare algorithm in O(1) space.
Detect a cycle in a linked list — from a hash set that tracks visited nodes to Floyd's two-pointer tortoise-and-hare algorithm in O(1) space.
Reorder a linked list into the pattern L0→Ln→L1→Ln-1→… — from an O(N) space array approach to an in-place O(1) space solution using find-midpoint, reverse, and merge.
Merge two sorted linked lists into one sorted list — an iterative dummy-head approach and a clean recursive solution.
Reverse a singly linked list — an iterative three-pointer approach in O(1) space, and a recursive solution that unwinds the chain from the tail.
Search a rotated sorted array for a target in O(log N) — identifying the sorted half at each step, or finding the pivot first and running a clean binary search.
Design a key-value store that supports timestamped writes and floor-timestamp reads — storing sorted timestamp lists per key and binary searching for the closest past entry.
Find the minimum element in a rotated sorted array in O(log N) — comparing mid against a running minimum, then improving to a clean right-anchor binary search.
Find the minimum eating speed to finish all banana piles within h hours — from a brute-force linear scan to binary search on the answer space, with a tightened lower bound optimization.
Search a sorted 2D matrix for a target — from row-by-row binary search O(M log N) to a full O(log M·N) single-pass by treating the matrix as a flattened array.
Search a sorted array for a target — from an O(N) two-pointer scan to the classic O(log N) binary search.