Posts tagged

Problem Solving

Binary Search: Not Just for Sorted Arrays

Reframes binary search as a general search-space reduction technique rather than a sorted-array lookup trick. Covers the classic template and the two bugs that break it, then extends the idea to 'search on the answer' problems like Koko Eating Bananas and Split Array Largest Sum, and to rotated sorted arrays. Works through six real interview problems with Python solutions, explains how to recognize a hidden binary search from monotonicity, and shows why the same 15-line template solves problems that look nothing like array lookup.

Recursion for Interviews: Think Before You Code

A mental model for solving recursion interview problems without tracing every call. Introduces the 'leap of faith': trust the recursive call to solve the smaller problem, then define only the base case, the reduction step, and the combine step. Applies the three-question framework to five real interview problems in Python: reversing a linked list, validating a BST with min/max bounds, generating subsets by include/exclude, counting climbing-stairs paths (with memoization), and generating balanced parentheses with backtracking. Covers the recursion-to-DP pipeline, Python's recursion limit, and the follow-up questions interviewers actually ask.

Two Pointer Technique: When to Use It and 6 Problems Solved

A pattern-recognition guide to the two pointer technique for coding interviews. Explains the three flavors (converging pointers on sorted data, fast/slow same-direction pointers, and pointers across two sequences) and the problem-statement signals that tell you which one to reach for. Works through six interview problems from easy to hard with Python solutions: Two Sum II, Valid Palindrome, Remove Duplicates from Sorted Array, Container With Most Water, 3Sum, and Trapping Rain Water. Covers why the converging-pointer proof works, the deduplication details that break 3Sum, and a checklist for spotting two pointer problems in the wild.