DevLift

Blog

Tutorials, guides, and insights to help you become a better developer.

Clear
Delete the `if (!numSet.has(num - 1))` guard from the standard LeetCode 128 solution and every test still passes, but the inner loop jumps from 31,999 iterations to 511,984,000 at n = 32,000.
AdminSeptember 18, 20266 min read
0/1 Knapsack: What the One-Array Rewrite Costs You
Collapsing the 0/1 knapsack DP table into a single array is taught as a free win, but it destroys the record of which items were chosen and introduces a loop-direction bug that returns a plausible wrong answer on roughly four instances in five.
AdminSeptember 16, 20267 min read
Nearly every explanation of LeetCode 84 says the monotonic stack stays strictly increasing, and an assertion dropped into the loop shows that is false on 45,502 of 50,000 random histograms.
AdminSeptember 8, 20267 min read
Evaluating Reverse Polish Notation Is Easy. Rejecting Bad Input Is the Job.
The stack loop that evaluates an RPN expression is fifteen lines, but it returns undefined for an empty array, NaN for a missing operand and -0 for a negative fraction, so the real work is deciding what your evaluator owes a caller who hands it nonsense.
AdminAugust 18, 20269 min read
Dijkstra's Algorithm, and the Four Places It Quietly Breaks
Dijkstra's algorithm is four lines of greedy logic wrapped in machinery that fails quietly, so this post builds a binary-heap implementation in TypeScript, differential-tests it against Floyd-Warshall on 4,000 random graphs, and measures what the heap, the Array.shift() queue and the stale-entry check actually cost.
AdminAugust 10, 202612 min read
Union Find: The Structure That Only Answers "Same Group?"
Union Find trades every graph question except one for speed, and measured tree heights show exactly what path compression and union by rank each buy you — with tested solutions to Redundant Connection, Number of Connected Components, and Accounts Merge.
AdminAugust 6, 20268 min read
A monotonic stack maintains elements in order and pops when that order breaks — finding the next greater element for every popped value in O(n) total.
AdminAugust 3, 20265 min read
The Two Sum problem is the "Hello World" of hash map problems. Most people solve it, move on, and treat it as a warmup. That's a mistake. The pattern behind Two Sum — trading space for lookup speed — shows up in dozens of harder problems.
AdminJuly 27, 20265 min read
Two mid-to-senior linked list problems that test data structure design: deep-copying a list with random pointers (O(1) space trick), and implementing LRU Cache in O(1).
AdminMarch 19, 20265 min read
Page 1 of 4Next

Stay in the Loop

Get notified about new courses, tutorials, and learning tips. No spam, unsubscribe anytime.