Skip to content

All104

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.

LeetCode 143 - Reorder List

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.

LeetCode 021 - Merge Two Sorted Lists

Merge two sorted linked lists into one sorted list — an iterative dummy-head approach and a clean recursive solution.

LeetCode 206 - Reverse Linked List

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.

LeetCode 033 - Search in Rotated Sorted Array

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.

LeetCode 981 - Time Based Key-Value Store

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.

LeetCode 153 - Find Minimum in Rotated Sorted Array

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.

LeetCode 875 - Koko Eating Bananas

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.

LeetCode 074 - Search a 2D Matrix

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.

LeetCode 704 - Binary Search

Search a sorted array for a target — from an O(N) two-pointer scan to the classic O(log N) binary search.