Home
Step 1: Learn the basics
Step 1.1: Things to Know in C++/Java/Python or any language
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| User Input / Output | Link | |||
| Data Types | Link | Link | ||
| If Else statements | Link | Link | ||
| Switch Statement | Link | Link | ||
| What are arrays, strings? | Link | |||
| For loops | Link | Link | ||
| While loops | Link | |||
| Functions (Pass by Reference and Value) | Link | Link | ||
| Time Complexity [Learn Basics, and then analyse in next Steps] | Link |
Step 1.3: Learn STL/Java-Collections or similar thing in your language
| Topic/Article | Solution | |
|---|---|---|
| Java Collections or C++ STL | Link |
Step 1.4: Know Basic Maths
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Count Digits | Link | Link | ||
| Reverse a Number | Link | Link | Link | |
| Check Palindrome | Link | Link | Link | |
| GCD Or HCF | Link | Link | ||
| Armstrong Numbers | Link | Link | Link | |
| Print all Divisors | Link | Link | ||
| Check for Prime | Link | Link |
Step 1.5: Learn Basic Recursion
Step 1.6: Learn Basic Hashing
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Hashing Theory | Link | |||
| Counting frequencies of array elements | Link | |||
| Find the highest/lowest frequency element | Link |
Step 2: Learn Important Sorting Techniques
Step 2.1: Sorting-I
| Topic/Article | GfG | Video | Leetcode | |
|---|---|---|---|---|
| Selection Sort | Link | Link | ||
| Bubble Sort | Link | Link | ||
| Insertion Sort | Link | Link |
Step 2.2: Sorting-II
| Topic/Article | GfG | Video | Leetcode | |
|---|---|---|---|---|
| Merge Sort | Link | Link | ||
| Recursive Bubble Sort | Link | |||
| Recursive Insertion Sort | Link | |||
| Quick Sort | Link | Link |
Step 3: Solve Problems on Arrays [Easy -> Medium -> Hard]
Step 3.1: Easy
Step 3.2: Medium
Step 3.3: Hard
Step 4: Binary Search [1D, 2D Arrays, Search Space]
Step 4.1: Learning BS on 1D Arrays
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Binary Search to find X in sorted array | Link | Link | ||
| Implement Lower Bound | Link | |||
| Implement Upper Bound | Link | |||
| Search Insert Position | Link | Link | ||
| Floor/Ceil in Sorted Array | ||||
| Find the first or last occurrence of a given number in a sorted array | Link | Link | ||
| Count occurrences of a number in a sorted array with duplicates | Link | |||
| Find peak element | Link | Link | ||
| Search in Rotated Sorted Array I | Link | Link | Link | |
| Search in Rotated Sorted Array II | Link | Link | ||
| Find minimum in Rotated Sorted Array | Link | Link | ||
| Find out how many times has an array been rotated | Link | |||
| Single element in a Sorted Array | Link | Link |
Step 4.2: Applying BS on 2D Arrays
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Find the row with maximum number of 1’s | Link | |||
| Search in a 2 D matrix | Link | Link | Link | |
| Find Peak Element | Link | Link | ||
| Matrix Median | Link | Link |
Step 4.3: Find Answers by BS in Search Space
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Find square root of a number in log n | Link | Link | ||
| Find the Nth root of a number using binary search | Link | |||
| Koko Eating Bananas | Link | Link | ||
| Minimum days to make M bouquets | Link | Link | ||
| Find the smallest Divisor | Link | Link | ||
| Capacity to Ship Packages within D Days | Link | Link | ||
| Median of two sorted arrays | Link | Link | Link | |
| Aggressive Cows | Link | Link | ||
| Book Allocation Problem | Link | Link | ||
| Split array – Largest Sum | Link | Link | ||
| Kth Missing Positive Number | Link | Link | ||
| Minimize Max Distance to Gas Station | Link | Link | ||
| Median of 2 sorted arrays | Link | Link | Link | |
| Kth element of 2 sorted arrays | Link | Link |
Step 5: Strings [Basic and Medium]
- String has extremely hard problems for beginners in its hard section, so it is covered in the later half
- String has lesser problems, because most of the string problems have hard concepts like DP or others which are covered in different topics.
Step 5.1: Basic and Easy String Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Remove outermost Paranthesis | Link | Link | ||
| Reverse words in a given string / Palindrome Check | Link | Link | ||
| Largest odd number in a string | Link | Link | ||
| Longest Common Prefix | Link | Link | ||
| Isomorphic String | Link | Link | ||
| check whether one string is a rotation of another | Link | Link | ||
| Check if two strings are anagram of each other | Link | Link |
Step 5.2: Medium String Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Sort Characters by frequency | Link | Link | ||
| Maximum Nesting Depth of Paranthesis | Link | Link | ||
| Roman Number to Integer and vice versa | Link | Link | ||
| Implement Atoi | Link | Link | ||
| Count Number of Substrings | Link | |||
| Longest Palindromic Substring[Do it without DP] | Link | Link | ||
| Sum of Beauty of all substring | Link | Link | ||
| Reverse Every Word in A String | Link | Link |
Step 6: LearnLinkedList [Single/Double LL, Medium, Hard]
Step 6.1: Learn 1DLinkedList
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Introduction toLinkedList, learn about struct, and how is node represented | Link | |||
| Inserting a node inLinkedList | Link | |||
| Deleting a node inLinkedList | Link | Link | ||
| Find the length of theLinkedlist [learn traversal] | Link | |||
| Search an element in the LL | Link |
Step 6.2: Learn DoublyLinkedList
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Introduction to DLL, learn about struct, and how is node represented | Link | |||
| Insert a node in DLL | Link | |||
| Delete a node in DLL | Link | |||
| Reverse a DLL | Link |
Step 6.3: Medium Problems of LL
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Middle of aLinkedList [TortoiseHare Method] | Link | Link | Link | |
| Reverse aLinkedList [Iterative] | Link | Link | Link | |
| Reverse a LL [Recursive] | Link | Link | Link | |
| Detect a loop in LL | Link | Link | Link | |
| Find the starting point in LL | Link | Link | Link | |
| Length of Loop in LL | Link | |||
| Check if LL is palindrome or not | Link | Link | Link | |
| Segrregate odd and even nodes in LL | Link | Link | ||
| Remove Nth node from the back of the LL | Link | Link | Link | |
| Delete the middle node of LL | Link | Link | ||
| Sort LL | Link | Link | ||
| Sort a LL of 0’s 1’s and 2’s by changingLinks | Link | |||
| Find the intersection point of Y LL | Link | Link | Link | |
| Add 1 to a number represented by LL | Link | |||
| Add 2 numbers in LL | Link | Link | Link |
Step 6.4: Medium Problems of DLL
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Delete all occurrences of a key in DLL | Link | |||
| Find pairs with given sum in DLL | Link | |||
| Remove duplicates from sorted DLL | Link |
Step 6.5: Hard Problems of LL
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Reverse LL in group of given size K | Link | Link | Link | |
| Rotate a LL | Link | Link | Link | |
| Flattening of LL | Link | Link | ||
| Clone aLinked List with random and next pointer | Link | Link | Link |
Step 7: Recursion [PatternWise]
- Please complete the basic recursion questions in Step 1
- To learn completely recursion, watch this playlist -> Link
Step 7.1: Get a Strong Hold
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Recursive Implementation of atoi() | Link | Link | ||
| Pow(x, n) | Link | Link | Link | |
| Count Good numbers | Link | Link | ||
| Sort a stack using recursion | Link | |||
| Reverse a stack using recursion | Link |
Step 7.2: Subsequences Pattern
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Generate all binary strings | Link | |||
| Generate Paranthesis | Link | Link | ||
| Print all subsequences/Power Set | Link | Link | Link | |
| Learn All Patterns of Subsequences (Theory) | Link | Link | ||
| Count all subsequences with sum K | Link | |||
| Check if there exists a subsequence with sum K | Link | |||
| Combination Sum | Link | Link | Link | |
| Combination Sum-II | Link | Link | Link | |
| Subset Sum-I | Link | Link | ||
| Subset Sum-II | Link | Link | Link | |
| Combination Sum – III | Link | Link | ||
| Letter Combinations of a Phone number | Link | Link |
Step 7.3: Trying out all Combos / Hard
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Palindrome Partitioning | Link | Link | Link | |
| Word Search | Link | Link | ||
| N Queen | Link | Link | Link | |
| Rat in a Maze | Link | Link | ||
| Word Break | Link | Link | ||
| M Coloring Problem | Link | Link | ||
| Sudoko Solver | Link | Link | Link | |
| Expression Add Operators | Link | Link |
Step 8: Bit Manipulation [Concepts & Problems] & Advanced Maths
- It is one of the smallest topics in DSA, learn the basic concepts.
- There are only few problems which are repeatedly asked in Interviews which have been added.
Step 8.1: Learn Bit Manipulation
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Introduction to Bit Manipulation [Theory] | Link | |||
| Check if the i-th bit is set or not | Link | |||
| Check if a number is odd or not | Link | |||
| Check if a number is power of 2 or not | Link | Link | ||
| Count the number of set bits | Link | |||
| Set/Unset the rightmost unset bit | Link | |||
| Swap two numbers | Link | |||
| Divide two integers without using multiplication, division and mod operator | Link | Link |
Step 8.2: Interview Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Count number of bits to be flipped to convert A to B | Link | Link | ||
| Find the number that appears odd number of times | Link | Link | ||
| Power Set | Link | Link | Link | |
| Fnd xor of numbers from L to R | Link | |||
| Find the two numbers appearing odd number of times | Link |
Step 9: Stack and Queues [Pre-In-Post-fix, Monotonic Stack]
Step 9.1: Learning
Step 9.2: Prefix, Infix, PostFix Conversion Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Infix to Postfix Conversion using Stack | Link | |||
| Prefix to Infix Conversion | Link | |||
| Prefix to Postfix Conversion | Link | |||
| Postfix to Prefix Conversion | Link | |||
| Postfix to Infix | Link | |||
| Convert Infix To Prefix Notation | Link |
Step 9.3: Monotonic Stack/Queue Problems [VVV. Imp]
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Next Greater Element | Link | Link | Link | |
| Next Greater Element 2 | Link | Link | ||
| Next Smaller Element | Link | |||
| Number of NGEs to the right | Link | |||
| Trapping Rainwater | Link | Link | Link | |
| Sum of subarray minimum | Link | Link | ||
| Stock span problem | Link | Link | ||
| Asteroid Collision | Link | Link | ||
| Sum of subarray ranges | Link | Link | ||
| Remove k Digits | Link | Link | ||
| Largest rectangle in a histogram | Link | Link | Link | |
| Maximal Rectangles | Link | Link |
Step 10: Sliding Window & Two Pointer Combined Problems
Step 10.1: Medium Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Longest Substring Without Repeating Characters | Link | Link | Link | |
| Max Consecutive Ones III | Link | Link | ||
| Fruit Into Baskets | Link | |||
| longest repeating character replacement | Link | Link | ||
| Binary subarray with sum | Link | Link | ||
| Count number of nice subarrays | Link | Link | ||
| Number of substring containing all three characters | Link | Link | ||
| Maximum point you can obtain from cards | Link | Link |
Step 11: Heaps [Learning, Medium, Hard Problems]
Step 11.1: Learning
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Introduction to Priority Queues using Binary Heaps | Link | |||
| Min Heap and Max Heap Implementation | Link | |||
| Check if an array represents a min-heap or not | Link | |||
| Convert min Heap to max Heap | Link |
Step 11.2: Medium Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Kth largest element in an array [use priority queue] | Link | Link | ||
| Kth smallest element in an array [use priority queue] | Link | |||
| Sort K sorted array | Link | |||
| Merge M sorted Lists | Link | Link | ||
| Replace each array element by its corresponding rank | Link | |||
| Task Scheduler | Link | Link | ||
| Hands of Straights | Link | Link |
Step 12: Greedy Algorithms [Easy, Medium/Hard]
Step 12.1: Easy Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Assign Cookies | Link | Link | ||
| Fractional Knapsack Problem | Link | Link | ||
| Greedy algorithm to find minimum number of coins | Link | Link | ||
| Lemonade Change | Link | Link | ||
| Valid Paranthesis Checker | Link | Link |
Step 12.2: Medium/Hard
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| N meetings in one room | Link | Link | ||
| Jump Game | Link | Link | ||
| Jump Game 2 | Link | Link | ||
| Minimum number of platforms required for a railway | Link | Link | ||
| Job sequencing Problem | Link | Link | ||
| Candy | Link | Link | ||
| Program for Shortest Job First (or SJF) CPU Scheduling | Link | |||
| Program for Least Recently Used (LRU) Page Replacement Algorithm | Link | |||
| Insert Interval | Link | Link | ||
| Merge Intervals | Link | Link | Link | |
| Non-overlapping Intervals | Link | Link |
Step 13: Binary Trees [Traversals, Medium and Hard Problems]
- An entire playlist is made on it, it is more than enough
Step 13.1: Traversals
Step 13.2: Medium Problems
Step 13.1: Hard Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Root to Node Path in Binary Tree | Link | Link | Link | |
| LCA in Binary Tree | Link | Link | Link | |
| Maximum width of a Binary Tree | Link | Link | Link | |
| Check for Children Sum Property | Link | Link | ||
| Print all the Nodes at a distance of K in a Binary Tree | Link | Link | Link | |
| Minimum time taken to BURN the Binary Tree from a Node | Link | Link | Link | |
| Count total Nodes in a COMPLETE Binary Tree | Link | Link | Link | |
| Requirements needed to construct a Unique Binary Tree | Theory | Link | Link | Link | |
| Construct Binary Tree from inorder and preorder | Link | Link | Link | |
| Construct the Binary Tree from Postorder and Inorder Traversal | Link | Link | Link | |
| Serialize and deserialize Binary Tree | Link | Link | Link | |
| Morris Preorder Traversal of a Binary Tree | Link | Link | Link | |
| Morris Inorder Traversal of a Binary Tree | Link | Link | Link | |
| Flatten Binary Tree toLinkedList | Link | Link | Link |
Step 14: Binary Search Trees [Concept and Problems]
- An entire playlist is made on it, it is more than enough
Step 14.1: Concepts
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Introduction to Binary Search Tree | Link | Link | ||
| Search in a Binary Search Tree | Link | Link | Link | |
| Find Min/Max in BST | Link |
Step 14.2: Practice Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Ceil in a Binary Search Tree | Link | Link | ||
| Floor in a Binary Search Tree | Link | Link | ||
| Insert a given Node in Binary Search Tree | Link | Link | Link | |
| Delete a Node in Binary Search Tree | Link | Link | Link | |
| Find K-th smallest/largest element in BST | Link | Link | Link | |
| Check if a tree is a BST or BT | Link | Link | Link | |
| LCA in Binary Search Tree | Link | Link | Link | |
| Construct a BST from a preorder traversal | Link | Link | Link | |
| Inorder Successor/Predecessor in BST | Link | Link | Link | |
| Merge 2 BST’s | Link | Link | Link | |
| Two Sum In BST | Check if there exists a pair with Sum K | Link | Link | Link | |
| Recover BST | Correct BST with two nodes swapped | Link | Link | Link | |
| Largest BST in Binary Tree | Link | Link |
Step 15: Graphs [Concepts & Problems]
- The new Graph playlist is under progress, you can check here -> Link
- In case you have lesser time, you can check the old graph series here -> Link
Step 15.1: Learning
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Graph and Types | Link | Link | ||
| Graph Representation | C++ | Link | Link | ||
| Graph Representation | Java | Link | Link | ||
| Connected Components | Logic Explanation | Link | Link | ||
| BFS | Link | Link | ||
| DFS | Link | Link |
Step 15.2: Problems on BFS/DFS
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Number of provinces (leetcode) | Link | Link | Link | |
| Connected Components Problem in Matrix | Link | |||
| Rotten Oranges | Link | Link | Link | |
| Flood fill | Link | Link | Link | |
| Cycle Detection in unirected Graph (bfs) | Link | Link | ||
| Cycle Detection in undirected Graph (dfs) | Link | Link | ||
| 0/1 Matrix (Bfs Problem) | Link | Link | Link | |
| Surrounded Regions (dfs) | Link | Link | Link | |
| Number of Enclaves [flood fill implementation – multisource] | Link | Link | Link | |
| Word ladder – 1 | Link | Link | ||
| Word ladder – 2 | Link | Link | ||
| Number of Distinct Islands [dfs multisource] | Link | Link | ||
| Bipartite Graph (DFS) | Link | Link | Link | |
| Cycle Detection in Directed Graph (DFS) | Link | Link |
Step 15.3: Topo Sort and Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Topo Sort | Link | Link | ||
| Kahn’s Algorithm | Link | Link | ||
| Cycle Detection in Directed Graph (BFS) | Link | Link | ||
| Course Schedule – I | Link | Link | Link | |
| Course Schedule – II | Link | Link | Link | |
| Find eventual safe states | Link | Link | Link | |
| Alien dictionary | Link | Link | Link |
Step 15.4: Shortest Path Algorithms and Problems
Step 15.5: MinimumSpanningTree/Disjoint Set and Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Minimum Spanning Tree | Link | Link | ||
| Prim’s Algorithm | Link | Link | ||
| Disjoint Set [Union by Rank] | Link | Link | ||
| Disjoint Set [Union by Size] | Link | Link | ||
| Kruskal’s Algorithm | Link | Link | ||
| Number of operations to make network connected | Link | Link | Link | |
| Most stones removed with same rows or columns | Link | Link | Link | |
| Accounts merge | Link | Link | Link | |
| Number of island II | Link | Link | Link | |
| Making a Large Island | Link | Link | Link | |
| Swim in rising water | Link | Link [HARD] |
Step 15.6: Other Algorithms
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Bridges in Graph | Link | Link | Link | |
| Articulation Point | Link | Link | ||
| Kosaraju’s Algorithm | Link | Link |
Step 16: Dynamic Programming [Patterns and Problems]
- An entire playlist is made on it, it is more than enough
Step 16.1: Introduction to DP
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Dynamic Programming Introduction | Link | Link |
Step 16.2: 1D DP
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Climbing Stars | Link | Link | Link | |
| Frog Jump(DP-3) | Link | Link | ||
| Frog Jump with k distances(DP-4) | Link | Link | ||
| Maximum sum of non-adjacent elements (DP 5) | Link | Link | ||
| House Robber (DP 6) | Link | Link |
Step 16.3: 2D/3D DP and DP on Grids
Step 16.4: DP on Subsequences
Step 16.5: DP on Strings
Step 16.6: DP on Stocks
Step 16.7: DP on LIS
Step 16.8: MCM DP | Partition DP
Step 16.9: DP on Squares
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Maximum Rectangle Area with all 1’s|(DP-55) | Link | Link | Link | |
| Count Square Submatrices with All Ones|(DP-56) | Link | Link | Link |
Step 17: Tries [Concepts and Problems]
- Trie has limited problems, and usually they ask directly.
- An entire playlist is made on it, you don’t need anything out of what is given below.
Step 17.1: Theory
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Implement TRIE | INSERT | SEARCH | STARTSWITH | Link | Link | Link |
Step 17.2: Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Implement Trie – 2 (Prefix Tree) | Link | Link | ||
| Longest String with All Prefixes | Link | Link | ||
| Number of Distinct Substrings in a String | Link | Link | ||
| Bit PreRequisites for TRIE Problems | Link | Link | ||
| Maximum XOR of two numbers in an array | Link | Link | Link | |
| Maximum XOR With an Element From Array | Link | Link | Link |
Step 18: Strings [Hard Problems and Standard Algos]
- Basic, Medium, and other concepts on Strings have been covered above.
- In this we cover the algorithms, and applications which are generally asked, it is slightly tough to understand intuition wise, so don’t be much concerned.
Step 18.1: Hard Problems
| Topic/Article | GfG | Solution | Leetcode | |
|---|---|---|---|---|
| Minimum number of bracket reversals needed to make an expression balanced | Link | Link | ||
| Count and say | Link | Link | ||
| Hashing In Strings | Theory | Link | |||
| Rabin Karp | Link | |||
| Z-Function | Link | |||
| KMP algo / LPS(pi) array | Link | |||
| Shortest Palindrome | Link | Link | ||
| Longest happy prefix | Link | Link | ||
| Count palindromic subsequence in given string | Link |