← All patterns

Review Challenges

A grab-bag of foundational problems that appear in interviews regardless of pattern. Two Sum, Maximum Subarray, Trapping Rain Water — the canonical warm-ups.

46 problems 12 Easy 29 Medium 5 Hard

A grab-bag of foundational problems that appear in interviews regardless of pattern. Two Sum, Maximum Subarray, Trapping Rain Water, Median of Two Sorted Arrays — the canonical warm-ups and the classics worth re-solving periodically. Each uses one of the earlier patterns; revisiting them ties the toolkit together.

Don't memorize solutions — recognize the pattern, then derive.

When to reach for this pattern

  • 'I have an interview tomorrow' — these are the must-knows
  • Foundational primitives that compose into harder problems
  • Worth re-solving every quarter to keep skills sharp

Canonical template

// Two Sum: hash-map complement lookup
unordered_map<int, int> seen;
for (int i = 0; i < (int)nums.size(); ++i) {
    int need = target - nums[i];
    if (seen.count(need)) return {seen[need], i};
    seen[nums[i]] = i;
}

// Maximum Subarray (Kadane)
int best = nums[0], curr = nums[0];
for (int i = 1; i < (int)nums.size(); ++i) {
    curr = max(nums[i], curr + nums[i]);
    best = max(best, curr);
}

C++ · adapt the names and types to your problem.

Common pitfalls

  • Don't memorize solutions verbatim — interviewers ask for variations
  • The 'classic' problems each demonstrate a pattern; identify which one before coding
  • Trapping Rain Water has 4+ solutions (DP, two-pointer, monotonic stack) — know the trade-offs
  • Median of Two Sorted Arrays in O(log min(m, n)) is a binary-search-on-partition — practice the index algebra

Related patterns

Problems (46)

Search ESC

Keyboard shortcuts

Shortcuts are disabled while typing in inputs.