progsu / gitPAID / DSA & LeetCode Strategy

DSA & LeetCode Strategy

essential intermediate

Efficient approach to data structures, algorithms, and coding interviews

DSA & LeetCode Strategy

Practice on progsu

91+ problems, built-in video solutions, and a leaderboard to track your progress:

Practice Problems

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:

  1. Watch the video solution first to understand the approach
  2. Code it yourself without looking — struggle is where learning happens
  3. If stuck for 20+ minutes, re-watch the video and try again
  4. 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
#ProblemVideo Solution
1Two SumVideo
2Contains DuplicateVideo
3Group AnagramsVideo
4Top K Frequent ElementsVideo
5Product of Array Except SelfVideo
6Encode and Decode StringsVideo
7Longest Consecutive SequenceVideo
8Maximum Subarray SumVideo

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
#ProblemVideo Solution
1Valid PalindromeVideo
2Two Sum II - Input Array Is SortedVideo
3Container With Most WaterVideo
43SumVideo
5Move ZeroesVideo
6Remove Duplicates from Sorted ArrayVideo
7Trapping Rain WaterVideo

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
#ProblemVideo Solution
1Valid ParenthesesVideo
2Min StackVideo
3Evaluate Reverse Polish NotationVideo
4Daily TemperaturesVideo
5Car FleetVideo
6Largest Rectangle in HistogramVideo

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?
#ProblemVideo Solution
1Search a 2D MatrixVideo
2Search in Rotated Sorted ArrayVideo
3Find Minimum in Rotated Sorted ArrayVideo
4Koko Eating BananasVideo
5Median of Two Sorted ArraysVideo

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
#ProblemVideo Solution
1Longest Substring Without Repeating CharactersVideo
2Minimum Window SubstringVideo
3Permutation in StringVideo
4Longest Repeating Character ReplacementVideo
5Sliding Window MaximumVideo

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
#ProblemVideo Solution
1Reverse Linked ListVideo
2Linked List CycleVideo
3Remove Nth Node From EndVideo
4Reorder ListVideo
5Add Two NumbersVideo

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
#ProblemVideo Solution
1Invert Binary TreeVideo
2Same TreeVideo
3Subtree of Another TreeVideo
4Lowest Common AncestorVideo
5Binary Tree Level Order TraversalVideo
6Validate Binary Search TreeVideo
7Kth Smallest Element in a BSTVideo

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
#ProblemVideo Solution
1Implement Trie (Prefix Tree)Video
2Design Add and Search Words Data StructureVideo
3Replace WordsVideo
4Word Search IIVideo

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
#ProblemVideo Solution
1SubsetsVideo
2Combination SumVideo
3PermutationsVideo
4N-QueensVideo
5Sudoku SolverVideo

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
#ProblemVideo Solution
1Kth Largest Element in a StreamVideo
2Last Stone WeightVideo
3Task SchedulerVideo
4Top K Frequent WordsVideo
5Merge K Sorted ListsVideo

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
#ProblemVideo Solution
1Number of IslandsVideo
2Course ScheduleVideo
3Pacific Atlantic Water FlowVideo
4Rotten OrangesVideo
5Word LadderVideo

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?
#ProblemVideo Solution
1Climbing StairsVideo
2Coin ChangeVideo
3Word BreakVideo
4Partition Equal Subset SumVideo

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
#ProblemVideo Solution
1Unique PathsVideo
2Longest Common SubsequenceVideo
3Distinct SubsequencesVideo
4Edit DistanceVideo

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
#ProblemVideo Solution
1Meeting RoomsVideo
2Insert IntervalVideo
3Non-overlapping IntervalsVideo
4Minimum Number of Arrows to Burst BalloonsVideo

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
#ProblemVideo Solution
1Maximum SubarrayVideo
2Valid Parenthesis StringVideo
3Gas StationVideo
4Hand of StraightsVideo

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)
#ProblemVideo Solution
1Network Delay TimeVideo
2Min Cost to Connect All PointsVideo

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
#ProblemVideo Solution
1Single NumberVideo
2Number of 1 BitsVideo
3Counting BitsVideo
4Missing NumberVideo
5Reverse IntegerVideo

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
#ProblemVideo Solution
1Rotate ImageVideo
2Set Matrix ZeroesVideo
3Spiral MatrixVideo
4Valid SudokuVideo
5Happy NumberVideo
6Pow(x, n)Video

Interview Day Tips

Success Strategy: During the actual interview, follow this framework for every problem:

  1. Clarify (1-2 min) — Repeat the problem, ask about edge cases, confirm input/output
  2. Plan (3-5 min) — Identify the pattern, explain your approach, discuss time/space complexity
  3. Code (15-20 min) — Write clean code, talk through your logic as you go
  4. 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

ComplexityNameExample
O(1)ConstantHash map lookup
O(log n)LogarithmicBinary search
O(n)LinearSingle pass through array
O(n log n)LinearithmicSorting
O(n^2)QuadraticNested loops (usually avoidable)
O(2^n)ExponentialBrute-force subsets