DSA Pattern Mapping Cheat Sheet
Array / Subarray
Disguised Problem Hidden Concept
Find maximum profit by buying and selling stock once Kadane’s Algorithm variation
Find if there’s a subarray with sum K Prefix sum + hashmap
Find length of longest subarray with equal 0s and 1s Prefix sum + hashmap (0 → -1 trick)
Aliens collect energy from non-adjacent pods House Robber DP
Rotate conveyor belt k steps Array rotation (reverse method)
Find trapped rainwater Two pointers / prefix max
Strings
Disguised Problem Hidden Concept
Find smallest substring containing all characters Sliding window + hashmap
Check if word can be rearranged into palindrome Character frequency count
Find longest repeating subsequence LCS DP variation
Find edit distance between two strings Edit Distance DP
Check if pattern exists in text KMP / Rabin-Karp / Z-algorithm
Greedy
Disguised Problem Hidden Concept
Schedule max tasks before deadlines Activity Selection / Interval Scheduling
Give minimum coins for amount Greedy Coin Change
Find minimum platforms at railway station Interval overlap (sort start/end times)
Cut minimum number of ropes Greedy + sorting
Graphs
Disguised Problem Hidden Concept
Number of islands in a grid DFS/BFS in 2D grid
Robot moves in maze, can it reach exit? BFS shortest path
Minimum cost to connect all cities MST (Prim/Kruskal)
Minimum flight price with k stops Dijkstra / BFS with level
Course schedule possible? Topological Sort / Cycle detection
Dynamic Programming (DP)
Disguised Problem Hidden Concept
Maximum gold in grid moving right/down Grid DP
Partition array into two equal subsets Subset Sum / Knapsack
Longest chain of increasing envelopes LIS (Longest Increasing Subsequence)
Decode message with digits Decode Ways DP
Climb stairs with 1 or 2 steps Fibonacci DP
Rod cutting for max revenue Unbounded Knapsack
Stacks / Queues
Disguised Problem Hidden Concept
Find next warmer day for each temperature Next Greater Element (stack)
Check if brackets are valid Stack parenthesis matching
Evaluate postfix expression Stack evaluation
Sliding window maximum Deque (Monotonic Queue)
Math / Number Theory
Disguised Problem Hidden Concept
Find missing number from 1..n XOR / Sum formula
Check if number is power of 2 Bit manipulation (n & (n-1))
Find gcd of fractions Euclidean Algorithm
Check if prime Sieve of Eratosthenes
Find modular inverse Extended Euclidean Algorithm / Fermat’s theorem