Shortest Subarray with Sum At Least K — Monotonic Deque on Prefix Sums
Solve LeetCode 862 Shortest Subarray with Sum At Least K in O(n) using a monotonic increasing deque on prefix sums. A FAANG hard interview classic.
1582 articles
Solve LeetCode 862 Shortest Subarray with Sum At Least K in O(n) using a monotonic increasing deque on prefix sums. A FAANG hard interview classic.
Solve LeetCode 286 Walls and Gates with multi-source BFS from every gate using a deque queue in O(m times n). A FAANG grid traversal classic.
Solve LeetCode 341 Flatten Nested List Iterator with a lazy stack-based approach in O(1) amortized hasNext and next. A FAANG design favorite at Google, Meta, and Amazon.
Solve LeetCode 1209 Remove All Adjacent Duplicates II in O(n) using a counter stack of (char, count) pairs. A FAANG-favorite stack twist asked at Google and Amazon.
Solve LeetCode 362 Design Hit Counter using a queue or fixed-size circular buffer for O(1) amortized hits and constant-time getHits. A FAANG system design favorite.