Pattern Wise goes topic by topic. Last Minute 100 is the short version for when the interview is close.
Building mastery one problem at a time — keep the momentum going!
Master data structures and algorithms topic by topic
Fundamental collection of elements stored at contiguous memory locations.
Use two indices that move towards or away from each other to reduce redundant comparisons.
Maintain a window of fixed size or expand/shrink it to satisfy a condition.
Precompute cumulative sums so any subarray or range sum can be answered in O(1).
Track the best subarray sum ending at each index and update the global maximum.
Sequence of characters and common string manipulation patterns.
Compare characters from both ends and move inward until the condition fails.
Maintain a moving window and adjust its size to satisfy character constraints.
Efficient search algorithm that divides the search interval in half.
Divide-and-conquer → narrow search space in sorted array.
Find first/last occurrence or smallest/largest index satisfying a condition.
Treat answer space as sorted → binary search to find minimum/maximum feasible value.
Apply binary search row-wise / column-wise or flattened array.
LIFO (Last In First Out) data structure patterns.
Maintain a monotonic increasing/decreasing stack to find next/prev greater/smaller, histogram ranges, or collisions.
Use two stacks or postfix evaluation to handle numbers and operators efficiently.
Simulate operations using a stack → pop on undo, remove adjacent duplicates, collapse characters.
Push opening symbols and validate closing ones; sometimes track count or score.
Use two stacks to implement another data structure or maintain extra info.
Combine stack properties with greedy choices to optimize strings or numbers.
Handle top/head element recursively → recurse on remaining stack/list → combine/insert results.
Understand FIFO operations and how front/rear work, including wrap-around in a fixed-size queue.
Elements must be processed in their arrival order. You repeatedly take the front element and either remove it or put it back at the rear.
Solving problems by breaking them down into smaller, self-similar subproblems.
Solve problems by reducing them to a simpler instance of the same problem.
Make multiple recursive calls at each step to explore different branches and combine their results.
Divide the problem into smaller subproblems, solve them recursively, and combine results.
Process data structures recursively by handling the first/last element and recursing on the rest.
Explore all possible subsets by choosing to include or exclude each element.
Linear data structure where elements are not stored at contiguous memory locations.
Directly manipulate pointers to insert, delete, traverse, and get length.
Use two pointers at different speeds to detect cycles, middle node, or duplicates.
Reverse entire list, partial list, or groups to reorder nodes.
Merge sorted lists, sort list using merge sort, or reorder using middle + reverse + merge.
Use a stack to handle backward traversal, carry logic, or next greater node.
Linked List with navigation in both forward and backward directions.
Maintain prev and next pointers carefully for insert, delete, traversal; use DLL + HashMap for O(1) cache operations.
Use DLL properties (prev/next) to efficiently merge, sort, reorder, flatten, or perform pointer-based checks.
Key-value pair data structure for O(1) average time complexity lookups.
Count elements to find majority, top-k frequent, or sort by frequency.
Track cumulative sums; map stores first occurrence → solve subarray sum problems.
Hierarchical data structure with a root value and subtrees of children.
Standard DFS → used for max depth, path sums, subtree calculations.
Use queue → traverse level by level → calculate sums, averages, or side views.
DFS recursion or parent-pointer mapping → find common ancestor efficiently.
Preorder / level-order encode-decode → reconstruct tree or flatten.
Leverage BST property (left < root < right) for search, insertion, deletion, and range queries.
Non-linear data structure consisting of nodes and edges.
DFS recursion or stack → track visited → identify connected components or detect cycles.
Standard BFS → track distance/levels → queue-based traversal → multi-source if needed.
DFS postorder or BFS (Kahn’s algorithm) → order nodes respecting dependencies.
Use Kruskal’s / Prim’s algorithm or Union-Find → find MST, minimum cost connections, or detect cycles.
Use priority queue → relax edges → track shortest distances.
Relax all edges V-1 times → detect negative cycles.
DP over adjacency matrix → shortest paths between all pairs of nodes.
Priority Queue data structure for efficient retrieval of highest/lowest priority elements.
Design heap.
Use min-heap for top-k largest, max-heap for top-k smallest → maintain heap of size k.
Use min-heap to merge multiple sorted arrays/lists efficiently.
Repeatedly combine the two smallest elements to minimize the total cost..
Algorithmic technique for solving problems recursively by trying to build a solution incrementally.
It is commonly used in problems that ask to generate all possible combinations, subsets, or permutations.
At each step, choose whether to include an element → explore all subsets/choices recursively.
Move in grid recursively → explore all valid paths → backtrack after each move.
Generate sequences or strings recursively by making a choice at each step.
Algorithm paradigm that follows the problem solving heuristic of making the locally optimal choice.
Sort intervals or extend reach as far as possible from current position → maximize tasks done / minimize steps.
Sort array or select elements → make locally optimal choice → achieve global optimum.
Optimization method involving breaking down problems into simpler subproblems and storing their solutions.
Track optimal solution using a 1D array → sequences, sums, or counts.
Use 2D array → track states for row/column → movement or path constraints.
Use 2D DP → index i,j represent substrings/subsequences → solve LCS, palindrome, or edit distance.
Track optimal solutions for subarrays/intervals → matrix chain, merging, or balloon burst patterns.
Recursion + memoization → track states along tree paths → post-order traversal.
Track states based on weight/value → classic 0-1 / bounded / unbounded variants.
State machine DP to track whether you are holding a stock or not.
Tree-based data structure used for efficiently storing and retrieving keys in a dataset of strings.
Build Trie → insert words → search full word or prefix efficiently → collect suggestions in lexicographic order.
Use Trie for fast lookup → combine with DP or backtracking for word segmentation and concatenation.
Use Trie for binary representation of numbers → efficiently find maximum/minimum XOR or subset XOR.
Techniques that perform operations on data at the bit level.
Use XOR / AND / OR / shift operations → detect single/missing numbers or count bits efficiently.
Iterate through all subsets using bits → solve combinatorial or DP counting problems.
Use XOR properties → maximize/minimize XOR over array/subarray or ranges.