100 DSA interview problems with solutions
This repository is your go-to resource for mastering Data Structures and Algorithms. I have curated a list of the top 100 DSA problems from LeetCode, covering a wide array of topics such as Array, String, Linked List, Graph, Dynamic Programming, Tree, Stack and Queue, and Miscellaneous. These problems are carefully selected to provide a comprehensive understanding of essential DSA concepts.
- Array
- String
- Linked List
- Graph
- Dynamic Programming
- Tree
- Stack and Queue
- Misc
Array | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Check if pair with the given Sum exists in Array | Link | Easy | |
2 | Best Time to Buy and Sell Stock | Link | Easy | |
3 | Find duplicates | Link | Medium | |
4 | Product of Array Except Self | Link | Medium | |
5 | Maximum Subarray | Link | Easy | |
6 | Maximum Product Subarray | Link | Medium | |
7 | Find Minimum in Rotated Sorted Array | Link | Medium | |
8 | Search in Rotated Sorted Array | Link | Medium | |
9 | 3 Sum | Link | Medium | |
10 | Container With Most Water | Link | Medium | |
11 | Find the Factorial of a large number | Link | Medium | |
12 | Trapping Rain Water | Link | Hard | |
13 | Chocolate Distribution Problem | Link | Medium | |
14 | Insert Interval | Link | Hard | |
15 | Merge Intervals | Link | Medium | |
16 | Non-overlapping Intervals | Link | Medium | |
17 | Set Matrix Zeroes | Link | Medium | |
18 | Spiral Matrix | Link | Medium |
String | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Longest Substring Without Repeating Characters | Link | Medium | |
2 | Longest Repeating Character Replacement | Link | Medium | |
3 | Smallest window in a String containing all characters of other String | Link | Hard | |
4 | Check whether two Strings are anagram of each other | Link | Easy | |
5 | Print all anagrams together | Link | Medium |
Linked List | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Reverse a Linked List | Link | Easy | Link |
2 | Detect Cycle in a Linked List | Link | Medium | Link |
3 | Merge Two Sorted Lists | Link | Easy | Link |
4 | Merge K Sorted Lists | Link | Hard | Link |
5 | Remove Nth Node From End Of List | Link | Medium | Link |
6 | Reorder List | Link | Medium | Link |
7 | Add 1 to a number represented as linked list | Link | Medium | Link |
8 | Find the middle of a given linked list | Link | Easy | Link |
9 | Delete last occurrence of an item from linked list | Link | Easy | Link |
Stack and Queue | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Check if given Parentheses expression is balanced or not | Link | Easy | Link |
2 | Delete middle element of a stack | Link | Medium | Link |
Tree and Graph | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Invert/Flip Binary Tree | Link | Easy | |
2 | Binary Tree Maximum Path Sum | Link | Hard | |
3 | Binary Tree Level Order Traversal | Link | Medium | |
4 | Serialize and Deserialize Binary Tree | Link | Hard | |
5 | Subtree of Another Tree | Link | Easy | |
6 | Construct Binary Tree from Preorder and Inorder Traversal | Link | Medium | |
7 | Validate Binary Search Tree | Link | Medium | |
8 | Kth Smallest Element in a BST | Link | Medium | |
9 | Lowest Common Ancestor of BST | Link | Easy | |
10 | Implement Trie (Prefix Tree) | Link | Medium | |
11 | Add and Search Word | Link | Medium |
Dynamic Programming | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Coin Change | Link | Medium | |
2 | 0/1 Knapsack Problem | Link | Medium | |
3 | Longest Increasing Subsequence | Link | Medium | |
4 | Longest Common Subsequence | Link | Medium | |
5 | Word Break Problem | Link | Medium | |
6 | Dice Throw | Link | Medium | |
7 | Egg Dropping Puzzle | Link | Hard | |
8 | Matrix Chain Multiplication | Link | Medium | |
9 | Combination Sum | Link | Medium | |
10 | Subset Sum Problem | Link | Medium | |
11 | Find maximum possible stolen value from houses | Link | Medium | |
12 | Count Possible Decodings of a given Digit Sequence | Link | Medium | |
13 | Unique paths in a Grid with Obstacles | Link | Medium | |
14 | Jump Game | Link | Medium | |
15 | Cutting a Rod | Link | Medium | |
16 | Maximum Product Cutting | Link | Medium | |
17 | Count number of ways to cover a distance | Link | Easy | |
18 | Number of 1 Bits | Link | Easy | |
19 | Counting Bits | Link | Medium | |
20 | Missing Number | Link | Easy | |
21 | Reverse Bits | Link | Easy | |
22 | Find XOR of all subsets of a set | Link | Medium |
Graph | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Detect Cycle in a Directed Graph | Link | Medium | |
2 | Bridges in a graph | Link | Hard | |
3 | Check whether a given graph is Bipartite or not | Link | Medium | |
4 | Strongly Connected Components | Link | Hard | |
5 | Topological Sorting | Link | Medium |
Miscellaneous | Problem | LeetCode Link | Difficulty Level | Solution |
---|---|---|---|---|
1 | Sentence Palindrome | Link | Easy | |
2 | Palindromic Substrings | Link | Medium | |
3 | Longest Common Prefix | Link | Easy | |
4 | Print Right View of a Binary Tree | Link | Medium | |
5 | Find the first circular tour that visits all petrol pumps | Link | Medium | |
6 | Length of the longest valid substring | Link | Hard | |
7 | Find the XOR of all subsets of a set | Link | Medium | |
8 | Detect Cycle in a Directed Graph | Link | Medium | |
9 | Bridges in a graph | Link | Medium | |
10 | Check whether a given graph is Bipartite or not | Link | Medium | |
12 | Find size of the largest region in Boolean Matrix | Link | Medium | |
13 | Flood fill Algorithm | Link | Medium | |
14 | Strongly Connected Components | Link | Medium | |
15 | Topological Sorting | Link | Medium | |
16 | Count ways to reach the n’th stair | Link | Easy | |
17 | Coin Change | Link | Medium | |
18 | 0/1 Knapsack Problem | Link | Medium | |
19 | Longest Increasing Subsequence | Link | Medium |