25 patterns:
🔹 1. Two Pointers
1. Two Sum II - Input Array is Sorted (LC 167)
2. Remove Duplicates from Sorted Array (LC 26)
3. Squares of a Sorted Array (LC 977)
4. 3Sum (LC 15)
5. 4Sum (LC 18)
6. Container With Most Water (LC 11)
7. Trapping Rain Water (LC 42)
8. Valid Palindrome (LC 125)
9. Move Zeroes (LC 283)
10. Partition Array (GFG)
🔹 2. Fast and Slow Pointers
1. Linked List Cycle (LC 141)
2. Linked List Cycle II (LC 142)
3. Middle of the Linked List (LC 876)
4. Happy Number (LC 202)
5. Find the Duplicate Number (LC 287)
6. Remove Nth Node From End (LC 19)
7. Reorder List (LC 143)
8. Palindrome Linked List (LC 234)
9. Circular Linked List (GFG)
10. Intersection of Linked Lists (LC 160)
🔹
25 patterns: 1
🔹 3. Sliding Window
1. Maximum Sum Subarray of Size K (GFG)
2. Minimum Window Substring (LC 76)
3. Longest Substring Without Repeating Characters (LC 3)
4. Longest Repeating Character Replacement (LC 424)
5. Permutation in String (LC 567)
6. Find All Anagrams in a String (LC 438)
7. Subarray Product Less Than K (LC 713)
8. Count Occurrences of Anagrams (GFG)
9. Max Consecutive Ones III (LC 1004)
10. Fruit Into Baskets (LC 904)
🔑 Sliding Window Template (General)
1. Left, Right pointers lo ( l=0 ).
2. Frequency / HashMap maintain karo.
3. Window expand karo (Right++):
freq update karo
koi condition check karo (e.g. distinct ≤ k, replace ≤ k, sum ≤ k)
4. Jab tak condition break ho, window shrink karo (Left++).
5. Har step pe answer update karo (max/min window length).
📌 Pattern wali problems
1. LeetCode 424 – Longest Repeating Character Replacement
👉 Condition: (window_size - maxFreq) ≤ k
2. LeetCode 1004 – Max Consecutive Ones III
25 patterns: 2
👉 Condition: (zeroCount ≤ k)
(Same as LC 424, bas zeroCount track karna hai.)
3. LeetCode 3 – Longest Substring Without Repeating
Characters
👉 Condition: jab tak freq[c] > 1 , shrink.
4. LeetCode 76 – Minimum Window Substring
👉 Condition: window valid tab jab sab required characters included ho jayein.
5. LeetCode 159 – Longest Substring with At Most Two Distinct
Characters
👉 Condition: distinctCount ≤ 2 .
✅ Thinking Flow (har problem ke liye)
Mujhe window me kya maintain karna hai?
(freq of chars, sum, distinct count, etc.)
Kab window invalid hoti hai?
(replace > k, sum > target, distinct > limit)
Invalid hote hi left++ karo.
🔹 4. Prefix Sum
1. Subarray Sum Equals K (LC 560)
2. Continuous Subarray Sum (LC 523)
3. Range Sum Query - Immutable (LC 303)
4. Range Sum Query 2D - Immutable (LC 304)
5. Maximum Size Subarray Sum Equals k (LC 325)
6. Equilibrium Point (GFG)
7. Count Subarrays with Sum Divisible by K (LC 974)
25 patterns: 3
8. Maximum Subarray (Kadane’s Algo, LC 53)
9. Binary Subarrays With Sum (LC 930)
10. Subarray Sums Divisible by K (GFG)
🔹 5. Merge Intervals
1. Merge Intervals (LC 56)
2. Insert Interval (LC 57)
3. Meeting Rooms (LC 252)
4. Meeting Rooms II (LC 253)
5. Minimum Number of Arrows to Burst Balloons (LC 452)
6. Non-overlapping Intervals (LC 435)
7. Employee Free Time (LC 759)
8. Interval List Intersections (LC 986)
9. Merge Overlapping Intervals (GFG)
10. Max Overlapping Intervals (GFG)
🔹 6. Binary Search
1. Binary Search (LC 704)
2. Search Insert Position (LC 35)
3. Search in Rotated Sorted Array (LC 33)
4. Find Minimum in Rotated Sorted Array (LC 153)
5. Find Peak Element (LC 162)
6. First and Last Position of Element in Sorted Array (LC 34)
7. Median of Two Sorted Arrays (LC 4)
8. Allocate Minimum Pages (GFG)
9. Painter Partition Problem (GFG)
25 patterns: 4
10. Aggressive Cows (GFG)
🔹 7. HashMap
1. Two Sum (LC 1)
2. Group Anagrams (LC 49)
3. Subarray Sum Equals K (LC 560)
4. Longest Consecutive Sequence (LC 128)
5. Isomorphic Strings (LC 205)
6. Word Pattern (LC 290)
7. Top K Frequent Elements (LC 347)
8. Find Duplicate Subtrees (LC 652)
9. Count Subarrays with Equal 0s, 1s, and 2s (GFG)
10. Largest Subarray with 0 Sum (GFG)
🔹 8. Stacks
1. Valid Parentheses (LC 20)
2. Min Stack (LC 155)
3. Next Greater Element I (LC 496)
4. Next Greater Element II (LC 503)
5. Daily Temperatures (LC 739)
6. Largest Rectangle in Histogram (LC 84)
7. Trapping Rain Water (LC 42)
8. Asteroid Collision (LC 735)
9. Celebrity Problem (GFG)
10. Stock Span Problem (GFG)
🔹
25 patterns: 5
🔹 9. Queues
1. Implement Queue using Stacks (LC 232)
2. Implement Stack using Queues (LC 225)
3. Sliding Window Maximum (LC 239)
4. Rotten Oranges (LC 994)
5. Number of Islands (LC 200)
6. Shortest Path in Binary Matrix (LC 1091)
7. Time Needed to Inform All Employees (LC 1376)
8. First Negative Integer in Every Window (GFG)
9. Circular Tour (GFG)
10. Petrol Pump Problem (GFG)
🔹 10. Heap / Priority Queue
1. Kth Largest Element in an Array (LC 215)
2. Top K Frequent Elements (LC 347)
3. Find Median from Data Stream (LC 295)
4. Mergek Sorted Lists (LC 23)
5. K Closest Points to Origin (LC 973)
6. Reorganize String (LC 767)
7. Task Scheduler (LC 621)
8. Kth Smallest Element in a Sorted Matrix (LC 378)
9. Nearly Sorted Array (GFG)
10. Connect Ropes to Minimize Cost (GFG)
🔹 11. K-way Merge (Min Heap)
1. Merge k Sorted Lists (LC 23)
25 patterns: 6
2. Merge k Sorted Arrays (GFG)
3. Smallest Range Covering Elements from k Lists (LC 632)
4. Find Median from Data Stream (LC 295)
5. Kth Largest Element in a Stream (LC 703)
6. K Pairs with Smallest Sums (LC 373)
7. Super Ugly Number (LC 313)
8. Top K Frequent Words (LC 692)
9. Running Median (GFG)
10. Merge Files Problem (GFG)
🔹 12. Trees
1. Maximum Depth of Binary Tree (LC 104)
2. Diameter of Binary Tree (LC 543)
3. Lowest Common Ancestor of a Binary Tree (LC 236)
4. Binary Tree Level Order Traversal (LC 102)
5. Binary Tree Right Side View (LC 199)
6. Symmetric Tree (LC 101)
7. Path Sum (LC 112)
8. Serialize and Deserialize Binary Tree (LC 297)
9. Boundary Traversal (GFG)
10. Vertical Order Traversal (GFG)
🔹 13. DFS
1. Number of Islands (LC 200)
2. Surrounded Regions (LC 130)
3. Word Search (LC 79)
25 patterns: 7
4. Flood Fill (LC 733)
5. Connected Components in Graph (LC 323)
6. Course Schedule (LC 207)
7. Pacific Atlantic Water Flow (LC 417)
8. Maximum Area of Island (LC 695)
9. Detect Cycle in Undirected Graph (GFG)
10. Detect Cycle in Directed Graph (GFG)
🔹 14. BFS
1. Binary Tree Level Order Traversal (LC 102)
2. Binary Tree Zigzag Level Order Traversal (LC 103)
3. Minimum Depth of Binary Tree (LC 111)
4. Word Ladder (LC 127)
5. Perfect Squares (LC 279)
6. Shortest Path in Binary Matrix (LC 1091)
7. Bus Routes (LC 815)
8. Rotten Oranges (LC 994)
9. Knight Walk (GFG)
10. Minimum Steps by Knight (GFG)
🔹 15. Graph Questions
1. Number of Connected Components (LC 323)
2. Clone Graph (LC 133)
3. Course Schedule (LC 207)
4. Course Schedule II (LC 210)
5. Graph Valid Tree (LC 261)
25 patterns: 8
6. Is Graph Bipartite? (LC 785)
7. Redundant Connection (LC 684)
8. Detect Cycle in Directed Graph (GFG)
9. Detect Cycle in Undirected Graph (GFG)
10. Topological Sort (GFG)
🔹 16. Dijkstra’s Algorithm
1. Network Delay Time (LC 743)
2. Path With Minimum Effort (LC 1631)
3. Cheapest Flights Within K Stops (LC 787)
4. Minimum Cost to Connect All Points (LC 1584)
5. Shortest Path in Binary Matrix (LC 1091)
6. Shortest Path in Weighted Undirected Graph (GFG)
7. Shortest Path in DAG (GFG)
8. Minimum Spanning Tree (GFG, Prim’s Algo)
9. City With the Smallest Number of Neighbors (LC 1334)
10. Dijkstra Implementation (GFG classic)
🔹 17. Topological Sort
1. Course Schedule (LC 207)
2. Course Schedule II (LC 210)
3. Alien Dictionary (LC 269)
4. Minimum Height Trees (LC 310)
5. Parallel Courses (LC 1136)
6. Longest Path in DAG (GFG)
7. Eventual Safe States (LC 802)
25 patterns: 9
8. Topological Sort (GFG)
9. Kahns Algorithm Practice (GFG)
10. Minimum Time to Complete Jobs (GFG)
🔹 18. Greedy
1. Activity Selection (GFG)
2. Job Sequencing Problem (GFG)
3. N Meetings in One Room (GFG)
4. Fractional Knapsack (GFG)
5. Minimum Number of Platforms (GFG)
6. Gas Station (LC 134)
7. Jump Game (LC 55)
8. Jump Game II (LC 45)
9. Candy Distribution (LC 135)
10. Minimum Number of Arrows to Burst Balloons (LC 452)
🔹 19. Dynamic Programming (DP)
1. Climbing Stairs (LC 70)
2. House Robber (LC 198)
3. House Robber II (LC 213)
4. Coin Change (LC 322)
5. Coin Change II (LC 518)
6. Longest Increasing Subsequence (LC 300)
7. Edit Distance (LC 72)
8. 0/1 Knapsack (GFG)
9. Matrix Chain Multiplication (GFG)
25 patterns: 10
10. Minimum Path Sum (LC 64)
🔹 20. Backtracking
1. N-Queens (LC 51)
2. N-Queens II (LC 52)
3. Sudoku Solver (LC 37)
4. Word Search (LC 79)
5. Rat in a Maze (GFG)
6. Generate Parentheses (LC 22)
7. Subsets (LC 78)
8. Subsets II (LC 90)
9. Combination Sum (LC 39)
10. Palindrome Partitioning (LC 131)
🔹 21. Bitwise Operations
1. Single Number (LC 136)
2. Single Number II (LC 137)
3. Single Number III (LC 260)
4. Missing Number (LC 268)
5. XOR Operation in an Array (LC 1486)
6. Counting Bits (LC 338)
7. Power of Two (LC 231)
8. Reverse Bits (LC 190)
9. Number of 1 Bits (LC 191)
10. Subsets Using Bitmask (LC 78, alternate solution)
25 patterns: 11