All roadmaps
DSAMedium → Hard

Python DSA — Senior Level

Hard patterns that separate senior engineers in FAANG and product company interviews. Two pointers, sliding window, recursion, stacks, queues, binary search, and dynamic programming.

20 problems~12h
1
Two Sum II — Sorted Arraymediumdsa

Two pointers on a sorted array — O(n) without extra space. The purest two-pointer problem to start with.

2
Three Summediumdsa

Sort + two pointers inside a loop — O(n²) with deduplication. The two-pointer pattern extended to triplets.

3
Container With Most Watermediumdsa

Greedy two-pointer shrink from both ends — a classic area maximization problem.

4
Boats to Save Peoplemediumdsa

Sort + greedy two-pointer (heaviest + lightest) — two-pointer as a greedy pairing strategy.

5
Longest Substring Without Repeating Charactersmediumdsa

Sliding window with a set — expand right, shrink left on duplicate. The canonical sliding window intro.

6
Max Consecutive Ones IIImediumdsa

Sliding window with a budget (k flips) — window shrinks when budget is exhausted. Core pattern.

7
Minimum Size Subarray Summediumdsa

Shrinkable sliding window — expand until sum ≥ target, then shrink. Variable-size window pattern.

8
Permutation in Stringmediumdsa

Fixed-size sliding window with frequency match — the window has constant length equal to pattern length.

9
Subarray Sum Equals Kmediumdsa

Prefix sum + hash map — count subarrays summing to k in O(n). Not solvable with plain sliding window.

10
Daily Temperaturesmediumdsa

Monotonic stack — maintain a stack of decreasing indices, pop when a warmer day is found.

11
Asteroid Collisionmediumdsa

Stack simulation with conditional pop — complex push/pop logic. Tests stack mastery beyond bracket matching.

12
Decode Stringmediumdsa

Stack for nested structure — push current string + count, build inner, then pop and multiply. Recursion-like.

13
Merge Intervalsmediumdsa

Sort by start + greedy merge — the canonical interval problem. Foundational for calendar and schedule questions.

14
Find First and Last Position in Sorted Arraymediumdsa

Binary search twice — left boundary and right boundary separately. The binary search extension pattern.

15
Search in Rotated Sorted Arraymediumdsa

Binary search with an extra condition to determine which half is sorted — classic binary search variation.

16
Top K Frequent Elementsmediumdsa

Counter + min-heap of size k — O(n log k). The heap pattern for top-N queries.

17
House Robberharddsa

DP with two choices per step: rob or skip — dp[i] = max(dp[i-2] + val, dp[i-1]). Classic 1D DP intro.

18
Coin Changeharddsa

Bottom-up DP with unbounded choices — dp[amount] = min coins. The textbook unbounded knapsack template.

19
Trapping Rain Waterharddsa

Two-pointer with prefix max — O(n) space reduction from the prefix array approach. A must-solve hard problem.

20
Minimum Window Substringharddsa

Sliding window with two frequency maps and a match counter — the hardest sliding window pattern.