DSA & LeetCode Strategy
Practice on progsu
91+ problems, built-in video solutions, and a leaderboard to track your progress:
Why DSA matters
Every major tech company tests data structures and algorithms in their interviews. Whether it’s FAANG, startups, or mid-size companies, you will be asked to solve coding problems on a whiteboard or in a shared editor.
- The good news: there are only ~15 core patterns that cover 90%+ of interview questions
- The bad news: you can’t cram this in a weekend — it takes consistent practice
- The strategy below gives you a structured path from zero to interview-ready
Quick Tip: Don’t grind 500 random problems. Focus on patterns first, then apply them across problems. Quality over quantity.
The Strategy: How to Actually Study
Step 1: Learn the pattern, not just the problem
Every problem below belongs to a pattern category. Before solving problems, understand the pattern:
- Watch the video solution first to understand the approach
- Code it yourself without looking — struggle is where learning happens
- If stuck for 20+ minutes, re-watch the video and try again
- Review your solution — can you explain it out loud?
Step 2: Follow the roadmap in order
The problems below are organized from Foundation to Expert. Each level builds on the previous one. Don’t skip ahead — the patterns compound.
Step 3: Track your progress
Track which problems you’ve completed and compete with others using the practice link above.
Important: Aim for 2-3 problems per day consistently rather than 20 problems in one day. Spaced repetition is how you retain patterns.
Foundation Level
These are your building blocks. Master these before moving on — nearly every harder problem uses these patterns.
Arrays + Hashing
Foundation for most problems — efficient lookups and storage.
Core idea: Use hash maps for O(1) lookups instead of brute-force nested loops. If you’re writing two nested for-loops, there’s almost always a hash map solution.
Strategy:
- Always ask: “Can I trade space for time with a hash map?”
- For frequency problems, use a counter/dictionary
- For “find pair” problems, store complements in a set
| # | Problem | Video Solution |
|---|---|---|
| 1 | Two Sum | Video |
| 2 | Contains Duplicate | Video |
| 3 | Group Anagrams | Video |
| 4 | Top K Frequent Elements | Video |
| 5 | Product of Array Except Self | Video |
| 6 | Encode and Decode Strings | Video |
| 7 | Longest Consecutive Sequence | Video |
| 8 | Maximum Subarray Sum | Video |
Two Pointers
Builds on arrays to solve search and pairing problems.
Core idea: Use two pointers moving toward each other (or in the same direction) to reduce O(n^2) to O(n). Works best on sorted arrays.
Strategy:
- Sort the array first if not already sorted
- Left pointer starts at beginning, right at end
- Move the pointer that gets you closer to your target
| # | Problem | Video Solution |
|---|---|---|
| 1 | Valid Palindrome | Video |
| 2 | Two Sum II - Input Array Is Sorted | Video |
| 3 | Container With Most Water | Video |
| 4 | 3Sum | Video |
| 5 | Move Zeroes | Video |
| 6 | Remove Duplicates from Sorted Array | Video |
| 7 | Trapping Rain Water | Video |
Stack
Adds memory of previous elements — great for parsing and monotonic problems.
Core idea: Use a stack when you need to remember previous elements and process them in reverse order (LIFO). If you see nested structures or “next greater/smaller” patterns, think stack.
Strategy:
- Matching brackets/parentheses = stack
- “Next greater element” = monotonic stack
- Evaluate expressions = stack with operators
| # | Problem | Video Solution |
|---|---|---|
| 1 | Valid Parentheses | Video |
| 2 | Min Stack | Video |
| 3 | Evaluate Reverse Polish Notation | Video |
| 4 | Daily Temperatures | Video |
| 5 | Car Fleet | Video |
| 6 | Largest Rectangle in Histogram | Video |
Binary Search
Builds on arrays for sorted search optimization.
Core idea: If the input is sorted (or has a monotonic property), you can eliminate half the search space each step. O(log n) instead of O(n).
Strategy:
- Classic binary search: find target in sorted array
- “Minimum/maximum that satisfies condition” = binary search on answer
- Always check: can I binary search the search space?
| # | Problem | Video Solution |
|---|---|---|
| 1 | Search a 2D Matrix | Video |
| 2 | Search in Rotated Sorted Array | Video |
| 3 | Find Minimum in Rotated Sorted Array | Video |
| 4 | Koko Eating Bananas | Video |
| 5 | Median of Two Sorted Arrays | Video |
Sliding Window
Extends array logic for subarray optimization.
Core idea: Maintain a “window” over a contiguous subarray/substring. Expand the right side, shrink the left side when constraints are violated. Turns O(n^2) substring problems into O(n).
Strategy:
- “Longest/shortest substring with condition” = sliding window
- Use a hash map to track window contents
- Expand right pointer, shrink left when window is invalid
| # | Problem | Video Solution |
|---|---|---|
| 1 | Longest Substring Without Repeating Characters | Video |
| 2 | Minimum Window Substring | Video |
| 3 | Permutation in String | Video |
| 4 | Longest Repeating Character Replacement | Video |
| 5 | Sliding Window Maximum | Video |
Intermediate Level
Linked & hierarchical structures. These build on your foundation patterns and introduce pointer manipulation and recursion.
Linked List
Core idea: Pointer manipulation. Most linked list problems are about rewiring .next pointers. Draw it out on paper first.
Strategy:
- Use a dummy node to simplify edge cases (empty list, single node)
- Fast and slow pointers detect cycles and find midpoints
- Reverse a linked list is a building block for many harder problems
| # | Problem | Video Solution |
|---|---|---|
| 1 | Reverse Linked List | Video |
| 2 | Linked List Cycle | Video |
| 3 | Remove Nth Node From End | Video |
| 4 | Reorder List | Video |
| 5 | Add Two Numbers | Video |
Trees
Core idea: Most tree problems are solved with DFS (recursive) or BFS (level-order with a queue). The recursive structure of trees maps naturally to recursive solutions.
Strategy:
- Ask: “Can I solve this with a recursive DFS?” — usually yes
- For level-by-level processing, use BFS with a queue
- BST property: left < root < right — use this for validation and search
| # | Problem | Video Solution |
|---|---|---|
| 1 | Invert Binary Tree | Video |
| 2 | Same Tree | Video |
| 3 | Subtree of Another Tree | Video |
| 4 | Lowest Common Ancestor | Video |
| 5 | Binary Tree Level Order Traversal | Video |
| 6 | Validate Binary Search Tree | Video |
| 7 | Kth Smallest Element in a BST | Video |
Tries
Core idea: A trie (prefix tree) stores strings character by character. Perfect for prefix matching, autocomplete, and word search problems.
Strategy:
- If the problem involves prefixes or dictionary lookups, think trie
- Each node has up to 26 children (for lowercase English)
- Mark end-of-word nodes to distinguish complete words from prefixes
| # | Problem | Video Solution |
|---|---|---|
| 1 | Implement Trie (Prefix Tree) | Video |
| 2 | Design Add and Search Words Data Structure | Video |
| 3 | Replace Words | Video |
| 4 | Word Search II | Video |
Advanced Patterns
Recursion & optimization. These patterns are harder but show up frequently in interviews at top companies.
Backtracking
Core idea: Build solutions incrementally and abandon (“backtrack”) paths that can’t lead to a valid solution. It’s DFS on a decision tree.
Strategy:
- Draw the decision tree first
- At each step: make a choice, recurse, undo the choice
- Prune early — skip branches that violate constraints
| # | Problem | Video Solution |
|---|---|---|
| 1 | Subsets | Video |
| 2 | Combination Sum | Video |
| 3 | Permutations | Video |
| 4 | N-Queens | Video |
| 5 | Sudoku Solver | Video |
Heap / Priority Queue
Core idea: Efficiently track the min/max element. Use a heap when you need repeated access to the smallest or largest item.
Strategy:
- “Top K” anything = heap
- Use a min heap of size K to find the Kth largest
- Use a max heap when you need the largest element quickly
| # | Problem | Video Solution |
|---|---|---|
| 1 | Kth Largest Element in a Stream | Video |
| 2 | Last Stone Weight | Video |
| 3 | Task Scheduler | Video |
| 4 | Top K Frequent Words | Video |
| 5 | Merge K Sorted Lists | Video |
Graphs
Core idea: Model problems as nodes and edges. Most graph problems use BFS (shortest path) or DFS (exploration/connected components).
Strategy:
- “Number of islands” type = DFS/BFS flood fill
- “Shortest path” = BFS (unweighted) or Dijkstra (weighted)
- “Can I complete all tasks?” = topological sort (cycle detection)
- Always track visited nodes to avoid infinite loops
| # | Problem | Video Solution |
|---|---|---|
| 1 | Number of Islands | Video |
| 2 | Course Schedule | Video |
| 3 | Pacific Atlantic Water Flow | Video |
| 4 | Rotten Oranges | Video |
| 5 | Word Ladder | Video |
Dynamic Programming (1-D)
Core idea: Break a problem into overlapping subproblems. Store results to avoid recomputation. If a recursive solution has repeated calls, DP can optimize it.
Strategy:
- Start with a recursive brute-force solution
- Add memoization (top-down) or build a DP table (bottom-up)
- Define your state clearly:
dp[i]= what does index i represent? - Find the recurrence relation — how does
dp[i]relate to previous values?
| # | Problem | Video Solution |
|---|---|---|
| 1 | Climbing Stairs | Video |
| 2 | Coin Change | Video |
| 3 | Word Break | Video |
| 4 | Partition Equal Subset Sum | Video |
Dynamic Programming (2-D)
Core idea: Same as 1-D DP but with two changing variables. dp[i][j] usually represents a subproblem on a substring, subarray, or grid.
Strategy:
- String comparison problems (edit distance, LCS) = 2D DP
- Grid traversal problems (unique paths) = 2D DP
- Draw out the DP table to visualize transitions
| # | Problem | Video Solution |
|---|---|---|
| 1 | Unique Paths | Video |
| 2 | Longest Common Subsequence | Video |
| 3 | Distinct Subsequences | Video |
| 4 | Edit Distance | Video |
Expert Level
Optimization & logic. These are the patterns that separate good from great in interviews.
Intervals
Core idea: Sort by start (or end) time, then process intervals linearly. Most interval problems become simple after sorting.
Strategy:
- Sort intervals by start time
- Compare current interval’s start with previous interval’s end
- Merge, insert, or count based on overlap
| # | Problem | Video Solution |
|---|---|---|
| 1 | Meeting Rooms | Video |
| 2 | Insert Interval | Video |
| 3 | Non-overlapping Intervals | Video |
| 4 | Minimum Number of Arrows to Burst Balloons | Video |
Greedy
Core idea: Make the locally optimal choice at each step. Greedy works when the local optimum leads to the global optimum.
Strategy:
- Ask: “Does choosing the best option right now hurt future choices?”
- If not, greedy works
- Often paired with sorting
| # | Problem | Video Solution |
|---|---|---|
| 1 | Maximum Subarray | Video |
| 2 | Valid Parenthesis String | Video |
| 3 | Gas Station | Video |
| 4 | Hand of Straights | Video |
Advanced Graphs
Core idea: Weighted graph algorithms. Dijkstra for shortest path, Prim’s/Kruskal’s for minimum spanning trees.
Strategy:
- “Shortest path with weights” = Dijkstra (use a min heap)
- “Connect all nodes with minimum cost” = MST (Prim’s or Kruskal’s)
| # | Problem | Video Solution |
|---|---|---|
| 1 | Network Delay Time | Video |
| 2 | Min Cost to Connect All Points | Video |
Bit Manipulation
Core idea: Use binary operations (AND, OR, XOR, shifts) for O(1) space tricks. XOR is especially powerful — a ^ a = 0 and a ^ 0 = a.
Strategy:
- “Find the single/missing number” = XOR everything
- Count bits with
n & (n - 1)to clear lowest set bit - Use bit shifts for powers of 2
| # | Problem | Video Solution |
|---|---|---|
| 1 | Single Number | Video |
| 2 | Number of 1 Bits | Video |
| 3 | Counting Bits | Video |
| 4 | Missing Number | Video |
| 5 | Reverse Integer | Video |
Math + Geometry
Core idea: Matrix manipulation, number theory, and spatial reasoning. These problems test your ability to think mathematically.
Strategy:
- Matrix rotation: transpose + reverse rows
- Spiral traversal: track boundaries (top, bottom, left, right)
- For number problems, think about mathematical properties first
| # | Problem | Video Solution |
|---|---|---|
| 1 | Rotate Image | Video |
| 2 | Set Matrix Zeroes | Video |
| 3 | Spiral Matrix | Video |
| 4 | Valid Sudoku | Video |
| 5 | Happy Number | Video |
| 6 | Pow(x, n) | Video |
Interview Day Tips
Success Strategy: During the actual interview, follow this framework for every problem:
- Clarify (1-2 min) — Repeat the problem, ask about edge cases, confirm input/output
- Plan (3-5 min) — Identify the pattern, explain your approach, discuss time/space complexity
- Code (15-20 min) — Write clean code, talk through your logic as you go
- Test (3-5 min) — Walk through an example, check edge cases, fix bugs
Important: If you get stuck, communicate. Say “I’m thinking about using X pattern because…” — interviewers want to see your thought process, not just the answer.
Common mistakes in interviews
- Jumping straight into code without a plan
- Going silent when stuck
- Not testing your solution with examples
- Ignoring edge cases (empty input, single element, duplicates)
- Over-engineering when a simple solution works
Time complexity cheat sheet
| Complexity | Name | Example |
|---|---|---|
| O(1) | Constant | Hash map lookup |
| O(log n) | Logarithmic | Binary search |
| O(n) | Linear | Single pass through array |
| O(n log n) | Linearithmic | Sorting |
| O(n^2) | Quadratic | Nested loops (usually avoidable) |
| O(2^n) | Exponential | Brute-force subsets |