DSA Pattern
Array
Sorted? → Use Binary Search or Two Pointers
Finding a subarray? → Use Sliding Window
Finding max/min sum? Use Kadane's Algorithm
String
Find a part of a string? → Use Sliding Window
Check if two strings match? → Use Pattern Matching (KMP)
Check if it's a palindrome? → Use Two Pointers
Linked List
Find middle or cycle? → Use Two Pointers
Reverse a linked list? → Use Iteration or Recursion
Merge two sorted lists? → Use Merge Sort
Tree
Go through all nodes? → Use DFS or BFS
Find lowest common ancestor? → Use DFS
Check if tree is balanced? → Use Recursion
Graph
Find connections? → Use DFS or BFS
Find shortest path? → Use Dijkstra's
Algorithm
Check for cycles? → Use Union-Find
Backtracking
Find all possible combinations? → Use Recursion
DSA Pattern 1
Solve a maze or puzzle? → Use
Backtracking
Dynamic Programming (DP)
Count ways to do something? → Use DP (Memoization)
Find longest increasing pattern? → Use DP Table
Solve knapsack-like problems? →
Use DP
Heap & Priority Queue
Find top K elements? → Use Heap
Sort multiple sorted lists? → Use Min Heap
Trie (For Words)
Find words that start with a letter? → Use Trie
Search a word fast? → Use Trie
Bit Manipulation
Find unique number? →Use XOR
Check if a number is power of 2? → Use Bitwise AND
DSA Pattern 2