DSA Patterns to crack 90% Interview Questions
Most questions can be solved using these underlying patterns!
If you like my work, please do consider subscribing to my FREE Newsletter to get more such content directly into your emails!
The following are the standard underlying DSA patterns that will help you solve 90% of the Interview Questions for TOP TECH COMPANIES:
✅ Sliding Window
Concept: Maintain a flexible window that expands and shrinks as you slide it until the constraint is satisfied. Track the optimal window size throughout.
Frequently Asked Problems:
✅ Two Pointers
Concept: Use two pointers moving either toward each other from opposite ends or in the same direction at different speeds. Make decisions based on the values they point to.
Frequently Asked Problems:
✅ Fast & Slow Pointers
Concept: Two pointers moving at different speeds through a linked list. Fast moves 2 steps, slow moves 1 step. If there’s a cycle, fast will eventually catch up to slow inside the cycle. If no cycle, fast reaches the end.
Frequently Asked Problems:
✅ Prefix Sum & Difference Array
Concept: Build a cumulative sum array where each position contains the sum of all previous elements OR store differences for range updates.
Sample Problems: Subarray Sum Equals K, Range Sum Query, Continuous Subarray Sum
✅ Monotonic Stack / Queue
Concept: Maintain a stack/queue in strictly increasing or decreasing order. When a new element would break this order, pop elements until the order is restored. The popped elements often represent “next greater/smaller” relationships.
Frequently Asked Problems:
✅ Frequency Counting: Hash Map / Set
Concept: Use HashMap for O(1) fast lookups to store key-value pairs and most importantly frequencies. Use HashSet for existence checking.
Frequently Asked Problems:
✅ Binary Search
Concept: Repeatedly eliminate half the search space by comparing the middle element to your target. Works on sorted arrays. Can search for exact values or “find the boundary” where a condition changes from true to false.
Frequently Asked Problems:
✅ Heap / Priority Queue
Concept: A tree-like structure where the smallest (min-heap) or largest (max-heap) element is always at the top. Use for problems requiring constant access to extreme values.
Frequently Asked Problems:
✅ Bit Manipulation
Concept: Use binary operations for efficient computation: XOR for finding unique elements, bit shifting for powers of 2, masks for subset generation. Often provides O(1) space solutions.
Frequently Asked Problems:
✅ BFS/DFS Traversal
Concept: Two fundamental ways to explore trees and graphs. Maintain variables like depth, sum, or path during traversal.
DFS goes deep using recursion/stack - perfect for path problems, connectivity, and exploring all possibilities.
BFS goes wide using a queue - guarantees shortest path in unweighted structures and handles level-by-level processing. Always mark visited nodes in graphs to avoid cycles.
BST property: left subtree < node < right subtree enables efficient searching.
Frequently Asked Problems:
✅ Interval Merging
Concept: Think of intervals as time slots on a calendar. To merge overlapping appointments, first sort them by start time, then walk through - if the current appointment starts before the previous one ends, they overlap so combine them.
Frequently Asked Problems:
✅ Backtracking
Concept: Generate all possible solutions by making choices, exploring recursively, then undoing choices (backtracking). Prune branches early when you know they won’t lead to valid solutions.
Frequently Asked Problems:
✅ Memoization
Concept: A top-down dynamic programming approach: Break the problem into smaller parts using recursion. If the same part shows up again, don’t solve it twice — just remember the answer in a dictionary/array and reuse it.
Frequently Asked Problems:
✅ Tabulation
Concept: A bottom-up dynamic programming approach: Build a DP table iteratively starting from the base cases. Ensure smaller subproblems are solved before larger ones so that each state can be filled directly without recursion. Often allows space optimization.
Frequently Asked Problems:
✅ Trie (Prefix Tree)
Concept: Tree where each node represents a character and paths represent strings. Efficient for prefix operations. Each node contains a map of character → next node, plus a flag marking word endings.
Frequently Asked Problems:
✅ Final Thoughts
Master these patterns and you’ll be able to solve 90% of LeetCode problems! Checkout my other FREE resources for interview prep:
Thanks for reading!


Can we collab