Skip to content

🧠 DSA Interview Prep — Pattern by Pattern #3

Description

@shaishab316

Goal: Crack FAANG/product company interviews by mastering patterns, not memorizing problems.
Track progress by checking off each problem as you solve it.


⚡ Pattern 1 — Arrays & Hashing

Key Idea: Use HashMaps/Sets for O(1) lookup. Think frequency count, index map, dedup.


👆 Pattern 2 — Two Pointers

Key Idea: Use left/right pointers on sorted arrays. Shrink the window based on condition.


🪟 Pattern 3 — Sliding Window

Key Idea: Expand right, shrink left. Track state (max, count, freq) inside the window.


📚 Pattern 4 — Stack

Key Idea: Use stack for next greater/smaller element, nested structures, monotonic problems.


🔍 Pattern 5 — Binary Search

Key Idea: Eliminate half the search space each step. Works on sorted arrays and monotonic functions.


🔗 Pattern 6 — Linked List

Key Idea: Use dummy nodes, fast/slow pointers, and in-place reversal techniques.


🌲 Pattern 7 — Trees (DFS / BFS)

Key Idea: Recursive DFS for path/depth problems. BFS (queue) for level-order traversal.


🔺 Pattern 8 — Heap / Priority Queue

Key Idea: Use min/max heap for top-K problems and streaming median.


🔄 Pattern 9 — Backtracking

Key Idea: Build solution incrementally, prune invalid branches early, restore state on undo.


🗺️ Pattern 10 — Graphs (DFS / BFS)

Key Idea: Track visited nodes. DFS for connected components, BFS for shortest path.


🏔️ Pattern 11 — Advanced Graphs

Key Idea: Dijkstra for weighted shortest path, Topological sort for DAGs, Union-Find for connectivity.


🧩 Pattern 12 — Dynamic Programming (1D)

Key Idea: Break into subproblems. Cache results. Think: "What decision do I make at each step?"


🧩 Pattern 13 — Dynamic Programming (2D)

Key Idea: Use 2D table. Classic: grid paths, edit distance, knapsack, string matching.


🌿 Pattern 14 — Greedy

Key Idea: Make the locally optimal choice at each step. Prove it leads to global optimum.


🔢 Pattern 15 — Intervals

Key Idea: Sort by start. Merge overlapping. Use sweep line for complex cases.


🔠 Pattern 16 — Tries

Key Idea: Prefix tree for fast string lookup, autocomplete, and prefix matching problems.


🧮 Pattern 17 — Bit Manipulation

Key Idea: XOR cancels duplicates. AND/OR/shift for bit-level tricks. O(1) space solutions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions