š§®
DSA
Patterns over solutions. Learn the 10ā15 core patterns and you can solve most interview problems from first principles.
Complexity reference
O(1)ConstantHash map lookup, array access
O(log n)LogarithmicBinary search, balanced BST
O(n)LinearLinear scan, single loop
O(n log n)LinearithmicMerge sort, heap sort
O(n²)QuadraticBubble sort, nested loops
O(2āæ)ExponentialRecursive subsets, brute force
Core patterns
Arrays & Strings
Two pointers, sliding window, prefix sum.
Linked Lists
Fast/slow pointers, reversal, cycle detection.
Trees & Graphs
BFS, DFS, binary trees, BST, graph traversals.
Sorting & Searching
Common sorts, binary search, and variations.
Dynamic Programming
Memoization, tabulation, common DP patterns.
ā Pattern Recognition
Before writing code, identify the pattern. Two pointers? Sliding window? BFS/DFS? DP? Picking the right pattern is 80% of the solution.
š” Interview Tip
Always state the brute force solution first, then optimize. It shows you understand the problem before jumping to complex solutions. Interviewers prefer a working O(n²) over a broken O(n log n).