Skip to main content
🧮

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

ā—† 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).