O(4^n / sqrt(n))Generate Parentheses: Backtracking, DP Intuition, and Pitfalls
Generate all valid parentheses for n using Catalan DP and backtracking. Explains correctness, memoization, C++ code, complexity, and pitfalls.
Daily records of problem solving and learning notes.
O(4^n / sqrt(n))Generate all valid parentheses for n using Catalan DP and backtracking. Explains correctness, memoization, C++ code, complexity, and pitfalls.
O(m * n)Solve Rotting Oranges using multi-source BFS: enqueue all rotten cells, track minutes with a time matrix, and compute the minimal rotting time.
O(n)Solve House Robber via dynamic programming: a choose-or-skip recurrence in O(n) time with O(1) space. Includes C++ code, proofs, pitfalls, and variants.
O(n log n)Learn how to merge overlapping intervals efficiently with a sort-and-scan approach in O(n log n), handling touching endpoints, plus C++ code and pitfalls.
O(1)Build an O(1) LRU cache using a hash map and doubly linked list with sentinels. Includes clean C++ code, invariants, pitfalls, and alternatives.