Tag: Coding Interview
15 posts
-
Two Pointers: Turning O(n²) Pair Searches into O(n), and Why It Works
The two pointers technique explained through why each move is safe: sorted pair sums, 3Sum, container with most water, in-place removal, and positive-only subarray sums, plus the input conditions each pattern silently depends on.
-
Sliding Window Technique: Fixed vs Variable Windows and When to Shrink
Sliding window algorithm optimizes fixed and variable-length contiguous ranges by sliding one position at a time in O(n).
-
Fixing TLE: Reading Constraints and Cutting Time Complexity in Coding Interviews
How to read N and Q to pick a target complexity, spot hidden O(N) steps inside loops, and replace nested loops with sorting, hashing, prefix sums or windows.
-
Hash Tables and Python dict: Hash Functions, Collisions and Why O(1) Is Only Average
Hash tables for coding interviews: how hash functions and collision resolution work, using Python dict and collections effectively, and the mistakes that turn O(1) lookups slow.
-
Binary Trees and BSTs: Traversals, Recursion Depth, Validation and Serialization
Binary trees for interviews: why the BST property covers whole subtrees, skewed trees and RecursionError, iterative traversals, level order, and serialization.
-
Bubble, Selection and Insertion Sort: Time Complexity and Why Insertion Sort Wins on Nearly Sorted Data
Bubble, selection and insertion sort in Python with their time complexity, why insertion sort wins on nearly sorted data, and how Timsort fits in.
-
Sorting Problems: Multi-Key Sorts, Custom Comparators, and When Sorting First Solves the Problem
Sorting interview problems in Python: stable multi-key sorts, cmp_to_key comparators, why sort-by-end greedy works, and comparator bugs that fail submissions.
-
Binary Search: Lower/Upper Bound, Binary Search on the Answer, and Off-by-One Traps
Binary search beyond "find x in a sorted array": loop invariants that keep bounds correct, lower and upper bound, binary search on the answer, and the off-by-one and infinite-loop bugs that fail interviews.
-
Backtracking: Pruning the Search Tree for Permutations, N-Queens and Sudoku
How backtracking prunes a search tree, why you undo instead of copy, and how pruning order and constraint checks decide whether permutations, N-Queens, and Sudoku finish in milliseconds or never.
-
Dynamic Programming: Memoization vs Tabulation and How to Spot a DP Problem
Dynamic programming from first principles: when it is valid, defining the state, memoization vs tabulation, lru_cache recursion limits, and table sizing bugs.
-
DP Patterns: Defining the State, Choosing Loop Order, and Recognizing Knapsack, LCS, and LIS
Dynamic programming patterns explained through the decisions that make them work: what dp[i] means, why 0-1 knapsack loops backward, why loop order turns combinations into permutations, and why the LIS tails array is not the LIS.
-
DP Problem Walkthroughs: Make One, Knapsack, Edit Distance, LIS and Partition With Reconstruction
Worked DP problems from state to reconstruction: recovering the path, items and edit script, and why rolling arrays break reconstruction unless you keep choices.
-
Greedy Algorithms: When the Locally Best Choice Works and How to Prove It
Why greedy works for interval scheduling and fractional knapsack but fails for coins {1,3,4} and 0/1 knapsack: exchange arguments, counterexamples, stress tests.
-
Arrays vs Linked Lists for Coding Interviews: Access Costs, Two Pointers and Common Traps
Arrays and linked lists for coding interviews: how their time complexities differ, the two-pointer and prefix-sum techniques that show up most, and practice problems by difficulty.
-
Stacks and Queues in Interviews: LIFO/FIFO Patterns, Monotonic Stacks and Deques
Stacks and queues for coding interviews: LIFO and FIFO behavior, the problem patterns they solve (bracket matching, BFS, monotonic stacks), and the mistakes that cost points.