# 🧠ARRAY (0-100) ## 📘 0-10: BASICS (Must Master First) Traversing an Array Finding Max / Min Elements Reversing an Array Swapping Elements Rotating Arrays (using reverse, temp array, etc.) Using Built-in Sort & Custom Comparators Multi-dimensional Arrays Array Initialization Tricks (fill, map, etc.) Printing Patterns using Arrays Edge Case Handling (empty, 1 element, duplicates) ## ⚙️ 11-30: CORE TECHNIQUES & PATTERNS Two Pointer Technique Reverse Array using 2 Pointers Sorted 2 Sum using 2 Pointers Remove Duplicates from Sorted Array Container With Most Water Sliding Window – Fixed Size Max Sum Subarray of Size K Sliding Window – Variable Size Longest Subarray with Condition Longest Substring with K Distinct Characters Max/Min of Subarrays (Deque) Prefix Sum Basics Range Sum Queries Subarray Sum Equals K Equilibrium Index Prefix XOR Subarray XOR Queries Longest Subarray with Given XOR Hashing / Frequency Count Finding Duplicates / Majority / Distincts ## 🧮 31-50: SEARCHING & SORTING Binary Search (Standard) First / Last Occurrence Binary Search on Answer Search in Rotated Sorted Array Find Peak Element Find K-th Smallest/Largest Sorting Tricks Sort + Two Pointers (3Sum, 4Sum) Sort Intervals Before Merge Sort for Greedy (activity selection) Count Sort / Bucket Sort Dutch National Flag Algorithm Cyclic Sort Find Missing/Duplicate (0-N, 1-N) Kadane's Algorithm (Max Subarray) Min Sum Subarray Start & End Index of Max Subarray Inversion Count using Merge Sort Wiggle Sort Sort Colors ## 🐢 51-65: ADVANCED PATTERNS Floyd's Cycle Detection (Tortoise & Hare) Detect Duplicate using Cycle Monotonic Stack / Next Greater Element Stock Span Trapping Rain Water Largest Rectangle in Histogram Greedy on Arrays Jump Game Gas Station Activity Selection Minimum Number of Platforms Merge Intervals Insert Interval Interval List Intersections Greedy + Sorting Problems ## 🧠 66-80: BIT / MATH / MASKING Bit Manipulation Tricks XOR – Find Unique Element Missing Number using XOR Swap without temp Bitmasking Subsets Generate All Subsets (Power Set) Bitmask DP (Subset Sum Type) Mathematical Logic Sum from 1 to N: n(n+1)/2 Difference between actual vs expected sum Modular Arithmetic on Array Prefix GCD / Suffix GCD LCM/GCD-based Problems Prime Factor Based Trick on Array XOR Prefix Logic ## 🧩 81-95: ADVANCED CONCEPTS & TRICKS Difference Array (for range updates) Construct Array from Differences Range Update in O(1) Next Permutation Rearranging Array Circular Arrays Wrap Around using % Gas Station (Circular) Subarray vs Subsequence vs Subset Max Sum Increasing Subsequence LIS using Binary Search Prefix + Hashing Optimization Count Inversions Longest Bitonic Subarray Longest Mountain Subarray ## ✅ 96-100: MUST-SOLVE PROBLEMS Reverse Array, Rotate Array, Move Zeroes Two Sum, 3Sum, Subarray Sum = K Max Product Subarray, Kadane’s Next Greater Element, Trapping Rain Water Search in Rotated Sorted Array, Merge Intervals --- --- # 💥STRINGS GUIDE (0-110) --- Everything you need to conquer all 110 types of String questions – cleanly grouped and leveled for full prep. ## 📘 0-15: STRING BASICS (Level: Easy) String Traversal Length, Indexing, and Substring Character Comparison String Reversal Palindrome Check String Concatenation ASCII Value / Character to Int Frequency Count using Map / Array String Sorting Changing Case (upper/lower) Removing Duplicates Counting Vowels / Consonants Split / Join Strings String Comparison (Lexicographic, etc.) String Immutability (understanding how strings are immutable in Java, Python, etc.) ## ⚙️ 16-35: PATTERNS & TECHNIQUES (Level: Easy-Medium) Two Pointer on Strings Reverse Words in a String Check Anagram (Sorting, Hashing) Group Anagrams First Non-Repeating Character Frequency of All Characters Longest Common Prefix Check if Rotation of Another String Valid Palindrome with Removal (LeetCode 680) Implement strStr() / IndexOf Count and Say String Compression Replace Substrings Remove Adjacent Duplicates Ransom Note (Magazine Letters) Pangram Check Substring vs Subsequence Minimum Add to Make Valid Parentheses Remove All Occurrences of Substring Roman to Integer ## 🧠 36–55: SLIDING WINDOW + HASHMAP (Level: Medium) Sliding Window on String Longest Substring Without Repeating Characters Longest Substring With At Most K Distinct Characters Permutation in String Minimum Window Substring Anagrams in a String Count All Anagram Occurrences Repeated DNA Sequences Substring With Concatenation of All Words Maximum Number of Vowels in Substring Check Inclusion of Permutation Longest Substring With Even Vowels Longest Substring With Equal 0s and 1s (for binary strings) Substrings with Exactly K Distinct Characters Substring with Sum Equal to K (apply prefix trick) Count Binary Substrings Number of Substrings With Only 1s Count Distinct Substrings (Set + Rolling Hash) Count Palindromic Substrings Length of Longest Palindrome That Can Be Built ## 🔁 56–75: DYNAMIC PROGRAMMING ON STRINGS (Level: Medium-Hard) Longest Palindromic Substring (DP) Longest Common Subsequence Longest Repeating Subsequence Edit Distance (Levenshtein Distance) Shortest Common Supersequence Count of Palindromic Subsequences Minimum Insertions/Deletions to Make Palindrome Interleaving Strings Wildcard Pattern Matching Regex Matching (with . and *) Word Break I Word Break II (Backtracking + Memo) Decode Ways (A->1, B->2...) Longest Palindromic Subsequence Minimum Swaps to Make Strings Equal Count Subsequences with Given Pattern Minimum Cuts for Palindrome Partitioning Number of Ways to Decode a String Is Subsequence (Greedy + 2 Pointer) Scramble String ## 🧪 76–95: TRICKS, STRUCTURES & OPTIMIZATION Z-Algorithm (Pattern Matching) KMP Algorithm for Pattern Search Rabin-Karp (Rolling Hash) Trie (Prefix Tree) – Insert/Search Word Search in Grid (DFS + Backtracking) Suffix Array + LCP Manacher’s Algorithm – Longest Palindromic Substring in O(n) Build Automaton / DFA for Regex Lexicographically Smallest Subsequence Remove K Digits Smallest Subsequence of Distinct Characters Reorganize String Longest Happy Prefix (KMP + Prefix Table) Count of Matching Subsequences Minimum Window to Contain Pattern Alien Dictionary (Topo Sort) Serialize and Deserialize String Frequency Sort String Multiplication / Addition (Implementing operations) String to Integer (atoi) ## 🚀 96–110: MUST-SOLVE STRING PROBLEMS & MISC Palindrome Pairs Multiply Strings Integer to Roman Roman to Integer Longest Word in Dictionary Compare Version Numbers Remove Invalid Parentheses Longest Duplicate Substring Repeated Substring Pattern Remove Palindromic Subsequences Base Conversion (Binary, Hex, etc.) Reverse Only Letters License Key Formatting Integer to English Words Find Smallest Window That Contains All Characters of Another String ## 📌 BONUS: Tips to Master Strings Always master hashing + sliding window first. Learn DP patterns on strings early. Use tries for prefix-related problems. Know when to use greedy, stack, or backtracking (e.g., for parentheses). Practice at least 10 problems from each category above. --- --- # 🧱 STACK ## ✅ Basics of Stack Follows LIFO (Last In, First Out) Operations: push, pop, peek, isEmpty Can be implemented using arrays or linked lists ## ✅ Monotonic Stack Pattern Maintain stack in increasing or decreasing order Solves: Next Greater Element Next Smaller Element Daily Temperatures Stock Span Largest Rectangle in Histogram Sum of Subarray Minimums ## ✅ Valid Parentheses & Bracket Matching Use stack to match opening/closing brackets Solves: Valid Parentheses Longest Valid Parentheses Minimum Add to Make Valid ## ✅ Expression Evaluation Use stack to convert and evaluate expressions: Infix ➝ Postfix/Prefix Evaluate Postfix Basic Calculator I, II, III ## ✅ Stack for String Manipulation Stack helps simplify or decode strings: Decode String ("3[a2[c]]") Remove Adjacent Duplicates Simplify Unix Path ## ✅ Min/Max Stack Maintain a second stack for tracking min/max Solves: Min Stack Max Stack ## ✅ Stack for Recursion Simulation Convert recursive solutions into iterative using stack DFS (Trees / Graphs) Custom function call simulation ## ✅ Custom Stack Design Implement a stack with custom behavior: Stack with increment operation Stack with middle element retrieval Stack using queues --- # 🧺 QUEUE ## ✅ Basics of Queue Follows FIFO (First In, First Out) Operations: enqueue, dequeue, peek, isEmpty Implement with arrays, linked list, or deque ## ✅ Circular Queue Fixed size queue Wrap around when full Used in: OS Scheduling Ring Buffers ## ✅ Monotonic Queue (Sliding Window) Maintain max or min in a sliding window Solves: Maximum in Sliding Window (LC 239) Minimum in Sliding Window ## ✅ Queue + BFS Level-order traversal in: Binary Trees Grids & Graphs Shortest Path problems Solves: Number of Islands (BFS) Rotting Oranges Walls and Gates ## ✅ Design Queue Variants LRU Cache (Queue + HashMap) Front-Middle-Back Queue Implement Stack using Queues ## ✅ Deque (Double-Ended Queue) Insert/delete from both ends Used in: Sliding Window problems Palindrome Checking Max/Min in Subarrays ## ✅ Priority Queue / Heap Use min-heap or max-heap to: Find Kth Largest Top K Frequent Merge K Sorted Lists Reorganize String Task Scheduling --- # 🔗 LINKED LIST ## ✅ Basics of Linked List Types: Singly, Doubly, Circular Node Structure: value, next (and prev for doubly) Key Operations: Insertion at head, tail, or position Deletion by value or position Traverse, search, reverse ## 🧠 Core Techniques ## 🔄 Reversing a Linked List Iterative & Recursive reversal Used in many interview patterns ## 🐇 Floyd’s Cycle Detection (Hare & Tortoise) Detect if a cycle exists Find the starting node of the cycle Count length of the cycle ## 🧪 Middle of Linked List Use slow and fast pointer Needed in: Reversing second half Palindrome check Splitting list in half ## 🔁 Merge Two Sorted Lists Recursive and Iterative Key in Merge Sort on Linked List ## 🔃 Merge K Sorted Lists Use Priority Queue / Min Heap Divide & Conquer ## 🧼 Deletion Techniques Delete node by value or position Delete given node without head (Leetcode 237) Delete nth node from end (two pointer method) ## 🔄 Palindrome Linked List Find middle Reverse second half Compare two halves ## 🧠 LRU Cache (LinkedList + HashMap) Doubly Linked List + Map for O(1) access Core of system design problems ## 🔁 Linked List Cycle Problems Detect if cycle exists (Floyd’s) Find start of cycle Remove cycle ## ⚙️ Clone Linked List with Random Pointer Use a hashmap Or interweave cloned nodes with original ## 🔁 Intersection of Two Linked Lists Two pointer approach If one hits null, jump to head of other list They'll meet at intersection ## 🧱 Flattening Linked Lists Multi-level linked list (with child pointers) Merge nodes like 2D matrix ⚔️ Sorting a Linked List Merge Sort is preferred (O(n log n)) Cannot use regular array sort due to node-based structure ## ✅ Common Practice Patterns Pattern Example Problem Reverse LL Reverse Linked List (LC 206) Cycle Detection Linked List Cycle (LC 141) Merge Lists Merge Two Sorted Lists (LC 21) Middle Element Middle of Linked List (LC 876) Palindrome Palindrome LL (LC 234) K-Group Reverse Reverse Nodes in k-Group (LC 25) Remove Nth from End LC 19 Copy Random Pointer LC 138 Intersection LC 160 LRU Cache LC 146 # 🌳 TREE – Ultimate Concept Checklist ## ✅ BASICS What is a Tree? Acyclic connected graph with n nodes and n-1 edges Binary Tree vs Binary Search Tree (BST) Binary Tree: max 2 children BST: left < root < right ## 🧠 MUST-KNOW TECHNIQUES ## 1️⃣ Tree Traversals Inorder (LNR) Preorder (NLR) Postorder (LRN) Level Order (BFS using Queue) Use: For solving almost every tree-based problem (build, validate, modify) ## 2️⃣ Recursion Patterns Top-down (passing info from root to leaf) Bottom-up (gather info from children) ## 3️⃣ DFS & BFS on Trees DFS (Inorder, Pre, Post) BFS (Level Order) ## 4️⃣ Binary Search Tree (BST) Insert/Delete/Search – O(log n) Validate BST (min/max approach) Floor & Ceil in BST Lowest Common Ancestor (LCA) ## 5️⃣ Tree Construction Build from: Inorder + Preorder Inorder + Postorder Level Order ## 6️⃣ Diameter of Binary Tree Longest path between any two nodes (may not pass through root) ## 7️⃣ Path Sum Patterns Path Sum = Target (hasPath) Count All Paths with Sum K Max Path Sum between Nodes ## 8️⃣ Serialize / Deserialize a Tree Store/Recover tree using Preorder + NULL markers LeetCode 297 style problems ## 9️⃣ Views of Tree Top View Bottom View Left View / Right View Vertical Order Traversal ## 🔟 Tree DP DP on Tree Nodes (e.g. Robbery, House Robber III) Subtree-based decisions ## 🧱 Advanced Trees Trie (Prefix Tree) Segment Tree Binary Indexed Tree (Fenwick Tree) AVL / Red-Black Trees (for advanced interviews) ## ✅ Popular Patterns to Practice Concept Example Traversals LC 94, 144, 145, 102 BST LC 700, 98, 701 LCA LC 236 Build Tree LC 105, 106 Path Sum LC 112, 113, 124 Diameter LC 543 Views GFG problems (Top, Bottom View) Serialize LC 297 Tree DP LC 337 Trie LC 208, 211 # 🌐 GRAPH – Ultimate Concept Checklist ## ✅ BASICS Types: Directed/Undirected, Weighted/Unweighted Representations: Adjacency List (preferred) Adjacency Matrix ## 🧠 CORE GRAPH ALGORITHMS ## 1️⃣ DFS & BFS (Graph) Use Visited Array / Set Handle Disconnected Graphs Detect Cycles: Undirected: DFS + parent check Directed: DFS + recursion stack ## 2️⃣ Topological Sort Only for Directed Acyclic Graphs (DAG) Kahn’s Algorithm (BFS) DFS + Stack Used in: Course Schedule (LC 207) Task Ordering ## 3️⃣ Dijkstra’s Algorithm Shortest path in weighted graphs Use Priority Queue (Min Heap) Time: O(E log V) ## 4️⃣ Bellman-Ford Works with negative weights Detects negative weight cycles ## 5️⃣ Floyd-Warshall All pairs shortest path (Dynamic Programming) ## 6️⃣ Union-Find (Disjoint Set) Used in: Detecting Cycles Kruskal’s Algorithm Path Compression + Union by Rank ## 7️⃣ MST (Minimum Spanning Tree) Kruskal’s Algorithm → Sort Edges + DSU Prim’s Algorithm → Min Heap ## 8️⃣ Bipartite Graph Can be colored with 2 colors Check using BFS/DFS ## 9️⃣ Bridges & Articulation Points Used in: Network reliability Critical Connections (LC 1192) ## 🔟 Graph Coloring m-Coloring Problem Sudoku Solver style backtracking ## 🧭 Shortest Path Techniques Algorithm Use Case Dijkstra Positive weights Bellman-Ford Negative weights Floyd-Warshall All pairs BFS Unweighted shortest path ## ✅ Popular Graph Problems Concept Example DFS/BFS LC 200 (No. of Islands), LC 695 Topo Sort LC 207, 210 Dijkstra LC 743, 787 Union Find LC 684, 547 Kruskal GFG: MST problems Prim’s LC 1584 Bipartite LC 785 Cycle Detection GFG, LC 261 Bridges LC 1192 # 📘Dynamic Programming? Dynamic Programming is solving overlapping subproblems with optimal substructure, storing results to avoid recomputation using Memoization (Top Down) or Tabulation (Bottom Up). ## 🔥 DP BASICS (Level 0-1) ## ✅ Must Understand First Recursion → Recursion with Memoization → Bottom-Up Tabulation Understanding subproblem definitions Base cases and recurrence relations Space optimization tricks ## 🧠 DP PATTERNS TO MASTER ## 1️⃣ Fibonacci Style (1D DP) Simple recurrence relation Recursion → Memo → Tabulation → Space Optimized ## 🧪 Problems: Fibonacci Climbing Stairs Min Cost Climbing Stairs ## 2️⃣ 0/1 Knapsack (Subset Problems) Choose or Don’t Choose pattern dp[i][w] = max(val[i] + dp[i-1][w-wt[i]], dp[i-1][w]) ## 🧪 Problems: 0/1 Knapsack Subset Sum Equal Sum Partition Count Subsets with Given Sum ## 3️⃣ Unbounded Knapsack You can take an element multiple times ## 🧪 Problems: Coin Change Rod Cutting Minimum Coins to Make Change ## 4️⃣ Longest Common Subsequence (LCS Family) Compare two strings/arrays with indices i and j 🧪 Problems: LCS Longest Palindromic Subsequence Shortest Common Supersequence Edit Distance Delete Operations for Two Strings ## 5️⃣ DP on Strings Palindromes, subsequences, substring tricks 🧪 Problems: Longest Palindromic Substring Count Palindromic Subsequences Decode Ways (A-Z → 1-26) Wildcard Matching ## 6️⃣ DP on Grids (2D DP) Moving in 2D matrix: down/right or all 4 directions 🧪 Problems: Unique Paths Minimum Path Sum Cherry Pickup Max Gold Mine Obstacle Grid ## 7️⃣ Partition DP Split string/array into partitions 🧪 Problems: Palindrome Partitioning Burst Balloons Matrix Chain Multiplication ## 8️⃣ Bitmask DP State includes set of used elements Use bitmask for subsets 🧪 Problems: Travelling Salesman Problem Count Vowel Permutations DP with visited sets ## 9️⃣ Digit DP Count numbers with digits satisfying conditions 🧪 Problems: Count numbers with unique digits Numbers <= N with at most K non-zero digits ## 🔟 Game Theory / Sprague Grundy / DP with Turns Turn-based strategy DP 🧪 Problems: Predict Winner Stone Game Nim Game Variants