📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Data Structures and Algorithms DSA Interview Patterns

DSA Interview Patterns

5 min read Quiz at the end
Ten DSA interview patterns — sliding window, two pointers, BFS/DFS, DP, heap, trie, union-find.

DSA Interview Patterns

PatternProblemsKey Data Structure
Sliding WindowMax subarray, Longest substring no repeatArray, HashSet
Two PointersTwo Sum sorted, 3Sum, Remove duplicatesSorted Array
Binary SearchSearch rotated array, Min in rotated, K closestSorted Array
BFSShortest path, Level order, IslandsQueue
DFS/BacktrackingPermutations, Subsets, N-QueensStack/Recursion
Dynamic ProgrammingLCS, Knapsack, Coin change, LISArray/HashMap
Heap / Priority QueueTop K, Merge K lists, K closestMin/Max Heap
TrieAutocomplete, Word search IITrie
Union-FindConnected components, Redundant connectionDSU
Monotonic StackNext greater element, Daily temperaturesStack
# Problem-solving framework
# 1. Clarify: edge cases, constraints, input size
# 2. Brute force: state the naive O(n^2) approach
# 3. Optimise: sliding window / hash / sort / DP
# 4. Code: clean, handle edge cases
# 5. Test: [], [x], large n, duplicates, negatives
Topic Quiz · 1 questions

Test your understanding before moving on

1. Which data structure is used to implement BFS efficiently?
💡 BFS uses a queue (FIFO) — nodes are explored level by level in the order they are discovered.