Soltuions to AlgoExpert Problems in C++ and Python with their optimal Space-Time Complexities.
- Arrays
- Binary Search Trees
- Binary Trees
- Dynamic Programming
- Famous Algorithms
- Graphs
- Greedy Algorithms
- Heaps
- Linked Lists
- Recursion
- Searching
- Sorting
- Stacks
- Strings
- Tries
- π© - Easy
- π¦ - Medium
- π₯ - Hard
- β¬ - Very Hard
S.No | Problem | Difficulty Level | Category | Solutions |
---|---|---|---|---|
1. | Two Number Sum | π© | Arrays | [Link](/Easy/Two Number Sum) |
2. | Validate Subsequence | π© | Arrays | [Link](/Easy/Validate Subsequence) |
3. | Sorted Squared Array | π© | Arrays | [Link](/Easy/Sorted Squared Array) |
4. | Tournament Winner | π© | Arrays | [Link](/Easy/Tournament Winner) |
5. | Non-Constructible Change | π© | Arrays | [Link](/Easy/Non-Constructible Change) |
6. | Transpose Matrix | π© | Arrays | [Link](/Easy/Transpose Matrix) |
7. | Three Number Sum | π¦ | Arrays | [Link](/Medium/Three Number Sum) |
8. | Smallest Difference | π¦ | Arrays | [Link](/Medium/Smallest Difference) |
9. | Move Element To End | π¦ | Arrays | [Link](/Medium/Move Element To End) |
10. | Monotonic Array | π¦ | Arrays | [Link](/Medium/Monotonic Array) |
11. | Spiral Traverse | π¦ | Arrays | [Link](/Medium/Spiral Traverse) |
12. | Longest Peak | π¦ | Arrays | [Link](/Medium/Longest Peak) |
13. | Array Of Products | π¦ | Arrays | [Link](/Medium/Array Of Products) |
14. | First Duplicate Value | π¦ | Arrays | [Link](/Medium/First Duplicate Value) |
15. | Merge Overlapping Intervals | π¦ | Arrays | [Link](/Medium/Merge Overlapping Intervals) |
16. | Best Seat | π¦ | Arrays | [Link](/Medium/Best Seat) |
17. | Zero Sum Subarray | π¦ | Arrays | [Link](/Medium/Zero Sum Subarray) |
18. | Missing Numbers | π¦ | Arrays | [Link](/Medium/Missing Numbers) |
19. | Majority Element | π¦ | Arrays | [Link](/Medium/Majority Element) |
20. | Sweet And Savory | π¦ | Arrays | [Link](/Medium/Sweet And Savory) |
21. | Four Number Sum | π₯ | Arrays | [Link](/Hard/Four Number Sum) |
22. | Subarray Sort | π₯ | Arrays | [Link](/Hard/Subarray Sort) |
23. | Largest Range | π₯ | Arrays | [Link](/Hard/Largest Range) |
24. | Min Rewards | π₯ | Arrays | [Link](/Hard/Min Rewards) |
25. | Zigzag Traverse | π₯ | Arrays | [Link](/Hard/Zigzag Traverse) |
26. | Longest Subarray With Sum | π₯ | Arrays | [Link](/Hard/Longest Subarray With Sum) |
27. | Knight Connection | π₯ | Arrays | [Link](/Hard/Knight Connection) |
28. | Count Squares | π₯ | Arrays | [Link](/Hard/Count Squares) |
29. | Apartment Hunting | β¬ | Arrays | [Link](/Very Hard/Apartment Hunting) |
30. | Calendar Matching | β¬ | Arrays | [Link](/Very Hard/Calendar Matching) |
31. | Waterfall Streams | β¬ | Arrays | [Link](/Very Hard/Waterfall Streams) |
32. | Minimum Area Rectangle | β¬ | Arrays | [Link](/Very Hard/Minimum Area Rectangle) |
33. | Line Through Points | β¬ | Arrays | [Link](/Very Hard/Line Through Points) |
34. | Find Closest Value In BST | π© | Binary Search Trees | [Link](/Easy/Find Closest Value In BST) |
35. | BST Construction | π¦ | Binary Search Trees | [Link](/Medium/BST Construction) |
36. | Validate BST | π¦ | Binary Search Trees | [Link](/Medium/Validate BST) |
37. | BST Traversal | π¦ | Binary Search Trees | [Link](/Medium/BST Traversal) |
38. | Min Height BST | π¦ | Binary Search Trees | [Link](/Medium/Min Height BST) |
39. | Find Kth Largest Value In BST | π¦ | Binary Search Trees | [Link](/Medium/Find Kth Largest Value In BST) |
40. | Reconstruct BST | π¦ | Binary Search Trees | [Link](/Medium/Reconstruct BST) |
41. | Same BSTs | π₯ | Binary Search Trees | [Link](/Hard/Same BSTs) |
42. | Validate Three Nodes | π₯ | Binary Search Trees | [Link](/Hard/Validate Three Nodes) |
43. | Repair BST | π₯ | Binary Search Trees | [Link](/Hard/Repair BST) |
44. | Right Smaller Than | β¬ | Binary Search Trees | [Link](/Very Hard/Right Smaller Than) |
45. | Branch Sums | π© | Binary Trees | [Link](/Easy/Branch Sums) |
46. | Node Depths | π© | Binary Trees | [Link](/Easy/Node Depths) |
47. | Evaluate Expression Tree | π© | Binary Trees | [Link](/Easy/Evaluate Expression Tree) |
48. | Invert Binary Tree | π¦ | Binary Trees | [Link](/Medium/Invert Binary Tree) |
49. | Binary Tree Diameter | π¦ | Binary Trees | [Link](/Medium/Binary Tree Diameter) |
50. | Find Successor | π¦ | Binary Trees | [Link](/Medium/Find Successor) |
51. | Height Balanced Binary Tree | π¦ | Binary Trees | [Link](/Medium/Height Balanced Binary Tree) |
52. | Merge Binary Trees | π¦ | Binary Trees | [Link](/Medium/Merge Binary Trees) |
53. | Symmetrical Tree | π¦ | Binary Trees | [Link](/Medium/Symmetrical Tree) |
54. | Split Binary Tree | π¦ | Binary Trees | [Link](/Medium/Split Binary Tree) |
55. | Max Path Sum In Binary Tree | π₯ | Binary Trees | [Link](/Hard/Max Path Sum In Binary Tree) |
56. | Find Nodes Distance K | π₯ | Binary Trees | [Link](/Hard/Find Nodes Distance K) |
57. | Iterative In-order Traversal | β¬ | Binary Trees | [Link](/Very Hard/Iterative In-order Traversal) |
58. | Flatten Binary Tree | β¬ | Binary Trees | [Link](/Very Hard/Flatten Binary Tree) |
59. | Right Sibling Tree | β¬ | Binary Trees | [Link](/Very Hard/Right Sibling Tree) |
60. | All Kinds Of Node Depths | β¬ | Binary Trees | [Link](/Very Hard/All Kinds Of Node Depths) |
61. | Compare Leaf Traversal | β¬ | Binary Trees | [Link](/Very Hard/Compare Leaf Traversal) |
62. | Max Subset Sum No Adjacent | π¦ | Dynamic Programming | [Link](/Medium/Max Subset Sum No Adjacent) |
63. | Number Of Ways To Make Change | π¦ | Dynamic Programming | [Link](/Medium/Number Of Ways To Make Change) |
64. | Min Number Of Coins For Change | π¦ | Dynamic Programming | [Link](/Medium/Min Number Of Coins For Change) |
65. | Levenshtein Distance | π¦ | Dynamic Programming | [Link](/Medium/Levenshtein Distance) |
66. | Number Of Ways To Traverse Graph | π¦ | Dynamic Programming | [Link](/Medium/Number Of Ways To Traverse Graph) |
67. | Max Sum Increasing Subsequence | π₯ | Dynamic Programming | [Link](/Hard/Max Sum Increasing Subsequence) |
68. | Longest Common Subsequence | π₯ | Dynamic Programming | [Link](/Hard/Longest Common Subsequence) |
69. | Min Number Of Jumps | π₯ | Dynamic Programming | [Link](/Hard/Min Number Of Jumps) |
70. | Water Area | π₯ | Dynamic Programming | [Link](/Hard/Water Area) |
71. | Knapsack Problem | π₯ | Dynamic Programming | [Link](/Hard/Knapsack Problem) |
72. | Disk Stacking | π₯ | Dynamic Programming | [Link](/Hard/Disk Stacking) |
73. | Numbers In Pi | π₯ | Dynamic Programming | [Link](/Hard/Numbers In Pi) |
74. | Maximum Sum Submatrix | π₯ | Dynamic Programming | [Link](/Hard/Maximum Sum Submatrix) |
75. | Maximize Expression | π₯ | Dynamic Programming | [Link](/Hard/Maximize Expression) |
76. | Dice Throws | π₯ | Dynamic Programming | [Link](/Hard/Dice Throws) |
77. | Juice Bottling | π₯ | Dynamic Programming | [Link](/Hard/Juice Bottling) |
78. | Max Profit With K Transactions | β¬ | Dynamic Programming | [Link](/Very Hard/Max Profit With K Transactions) |
79. | Palindrome Partitioning Min Cuts | β¬ | Dynamic Programming | [Link](/Very Hard/Palindrome Partitioning Min Cuts) |
80. | Longest Increasing Subsequence | β¬ | Dynamic Programming | [Link](/Very Hard/Longest Increasing Subsequence) |
81. | Longest String Chain | β¬ | Dynamic Programming | [Link](/Very Hard/Longest String Chain) |
82. | Square of Zeroes | β¬ | Dynamic Programming | [Link](/Very Hard/Square of Zeroes) |
83. | Kadane's Algorithm | π¦ | Famous Algorithms | [Link](/Medium/Kadane's Algorithm) |
84. | Stable internships | π¦ | Famous Algorithms | [Link](/Medium/Stable internships) |
85. | Union Find | π¦ | Famous Algorithms | [Link](/Medium/Union Find) |
86. | Dijkstra's Algorithm | π₯ | Famous Algorithms | [Link](/Hard/Dijkstra's Algorithm) |
87. | Topological Sort | π₯ | Famous Algorithms | [Link](/Hard/Topological Sort) |
88. | Kruskal's Algorithm | π₯ | Famous Algorithms | [Link](/Hard/Kruskal's Algorithm) |
89. | KnuthβMorrisβPratt Algorithm | β¬ | Famous Algorithms | [Link](/Very Hard/KnuthβMorrisβPratt Algorithm) |
90. | A* Algorithm | β¬ | Famous Algorithms | [Link](/Very Hard/A* Algorithm) |
91. | Depth-first Search | π© | Graphs | [Link](/Easy/Depth-first Search) |
92. | Single Cycle Check | π¦ | Graphs | [Link](/Medium/Single Cycle Check) |
93. | Breadth-first Search | π¦ | Graphs | [Link](/Medium/Breadth-first Search) |
94. | River Sizes | π¦ | Graphs | [Link](/Medium/River Sizes) |
95. | Youngest Common Ancestor | π¦ | Graphs | [Link](/Medium/Youngest Common Ancestor) |
96. | Remove Islands | π¦ | Graphs | [Link](/Medium/Remove Islands) |
97. | Cycle In Graph | π¦ | Graphs | [Link](/Medium/Cycle In Graph) |
98. | Minimum Passes Of Matrix | π¦ | Graphs | [Link](/Medium/Minimum Passes Of Matrix) |
99. | Two-Colorable | π¦ | Graphs | Link |
100. | Boggle Board | π₯ | Graphs | [Link](/Hard/Boggle Board) |
101. | Largest Island | π₯ | Graphs | [Link](/Hard/Largest Island) |
102. | Rectangle Mania | β¬ | Graphs | [Link](/Very Hard/Rectangle Mania) |
103. | Detect Arbitrage | β¬ | Graphs | [Link](/Very Hard/Detect Arbitrage) |
104. | Two-Edge-Connected Graph | β¬ | Graphs | [Link](/Very Hard/Two-Edge-Connected Graph) |
105. | Airport Connections | β¬ | Graphs | [Link](/Very Hard/Airport Connections) |
106. | Minimum Waiting Time | π© | Greedy Algorithms | [Link](/Easy/Minimum Waiting Time) |
107. | Class Photos | π© | Greedy Algorithms | [Link](/Easy/Class Photos) |
108. | Tandem Bicycle | π© | Greedy Algorithms | [Link](/Easy/Tandem Bicycle) |
109. | Optimal Freelancing | π© | Greedy Algorithms | [Link](/Easy/Optimal Freelancing) |
110. | Task Assignment | π¦ | Greedy Algorithms | [Link](/Medium/Task Assignment) |
111. | Valid Starting City | π¦ | Greedy Algorithms | [Link](/Medium/Valid Starting City) |
112. | Min Heap Construction | π¦ | Heaps | [Link](/Medium/Min Heap Construction) |
113. | Continuous Median | π₯ | Heaps | [Link](/Hard/Continuous Median) |
114. | Sort K-Sorted Array | π₯ | Heaps | [Link](/Hard/Sort K-Sorted Array) |
115. | Laptop Rentals | π₯ | Heaps | [Link](/Hard/Laptop Rentals) |
116. | Merge Sorted Arrays | β¬ | Heaps | [Link](/Very Hard/Merge Sorted Arrays) |
117. | Remove Duplicates From Linked List | π© | Linked Lists | [Link](/Easy/Remove Duplicates From Linked List) |
118. | Middle Node | π© | Linked Lists | [Link](/Easy/Middle Node) |
119. | Linked List Construction | π¦ | Linked Lists | [Link](/Medium/Linked List Construction) |
120. | Remove Kth Node From End | π¦ | Linked Lists | [Link](/Medium/Remove Kth Node From End) |
121. | Sum of Linked Lists | π¦ | Linked Lists | [Link](/Medium/Sum of Linked Lists) |
122. | Merging Linked Lists | π¦ | Linked Lists | [Link](/Medium/Merging Linked Lists) |
123. | Find Loop | π₯ | Linked Lists | [Link](/Hard/Find Loop) |
124. | Reverse Linked List | π₯ | Linked Lists | [Link](/Hard/Reverse Linked List) |
125. | Merge Linked Lists | π₯ | Linked Lists | [Link](/Hard/Merge Linked Lists) |
126. | Shift Linked List | π₯ | Linked Lists | [Link](/Hard/Shift Linked List) |
127. | LRU Cache | β¬ | Linked Lists | [Link](/Very Hard/LRU Cache) |
128. | Rearrange Linked List | β¬ | Linked Lists | [Link](/Very Hard/Rearrange Linked List) |
129. | Linked List Palindrome | β¬ | Linked Lists | [Link](/Very Hard/Linked List Palindrome) |
130. | Zip Linked List | β¬ | Linked Lists | [Link](/Very Hard/Zip Linked List) |
131. | Node Swap | β¬ | Linked Lists | [Link](/Very Hard/Node Swap) |
132. | Nth Fibonacci | π© | Recursion | [Link](/Easy/Nth Fibonacci) |
133. | Product Sum | π© | Recursion | [Link](/Easy/Product Sum) |
134. | Permutations | π¦ | Recursion | Link |
135. | Powerset | π¦ | Recursion | Link |
136. | Phone Number Mnemonics | π¦ | Recursion | [Link](/Medium/Phone Number Mnemonics) |
137. | Staircase Traversal | π¦ | Recursion | [Link](/Medium/Staircase Traversal) |
138. | Blackjack Probability | π¦ | Recursion | [Link](/Medium/Blackjack Probability) |
139. | Reveal Minesweeper | π¦ | Recursion | [Link](/Medium/Reveal Minesweeper) |
140. | Lowest Common Manager | π₯ | Recursion | [Link](/Hard/Lowest Common Manager) |
141. | Interweaving Strings | π₯ | Recursion | [Link](/Hard/Interweaving Strings) |
142. | Solve Sudoku | π₯ | Recursion | [Link](/Hard/Solve Sudoku) |
143. | Generate Div Tags | π₯ | Recursion | [Link](/Hard/Generate Div Tags) |
144. | Ambiguous Measurements | π₯ | Recursion | [Link](/Hard/Ambiguous Measurements) |
145. | Number Of Binary Tree Topologies | β¬ | Recursion | [Link](/Very Hard/Number Of Binary Tree Topologies) |
146. | Non-Attacking Queens | β¬ | Recursion | [Link](/Very Hard/Non-Attacking Queens) |
147. | Binary Search | π© | Searching | [Link](/Easy/Binary Search) |
148. | Find Three Largest Numbers | π© | Searching | [Link](/Easy/Find Three Largest Numbers) |
149. | Search In Sorted Matrix | π¦ | Searching | [Link](/Medium/Search In Sorted Matrix) |
150. | Shifted Binary Search | π₯ | Searching | [Link](/Hard/Shifted Binary Search) |
151. | Search For Range | π₯ | Searching | [Link](/Hard/Search For Range) |
152. | Quickselect | π₯ | Searching | Link |
153. | Index Equals Value | π₯ | Searching | [Link](/Hard/Index Equals Value) |
154. | Median Of Two Sorted Arrays | β¬ | Searching | [Link](/Very Hard/Median Of Two Sorted Arrays) |
155. | Optimal Assembly Line | β¬ | Searching | [Link](/Very Hard/Optimal Assembly Line) |
156. | Bubble Sort | π© | Sorting | [Link](/Easy/Bubble Sort) |
157. | Insertion Sort | π© | Sorting | [Link](/Easy/Insertion Sort) |
158. | Selection Sort | π© | Sorting | [Link](/Easy/Selection Sort) |
159. | Three Number Sort | π¦ | Sorting | [Link](/Medium/Three Number Sort) |
160. | Quick Sort | π₯ | Sorting | [Link](/Hard/Quick Sort) |
161. | Heap Sort | π₯ | Sorting | [Link](/Hard/Heap Sort) |
162. | Radix Sort | π₯ | Sorting | [Link](/Hard/Radix Sort) |
163. | Merge Sort | β¬ | Sorting | [Link](/Very Hard/Merge Sort) |
164. | Count Inversions | β¬ | Sorting | [Link](/Very Hard/Count Inversions) |
165. | Min Max Stack Construction | π¦ | Stacks | [Link](/Medium/Min Max Stack Construction) |
166. | Balanced Brackets | π¦ | Stacks | [Link](/Medium/Balanced Brackets) |
167. | Sunset Views | π¦ | Stacks | [Link](/Medium/Sunset Views) |
168. | Best Digits | π¦ | Stacks | [Link](/Medium/Best Digits) |
169. | Sort Stack | π¦ | Stacks | [Link](/Medium/Sort Stack) |
170. | Next Greater Element | π¦ | Stacks | [Link](/Medium/Next Greater Element) |
171. | Reverse Polish Notation | π¦ | Stacks | [Link](/Medium/Reverse Polish Notation) |
172. | Colliding Asteroids | π¦ | Stacks | [Link](/Medium/Colliding Asteroids) |
173. | Shorten Path | π₯ | Stacks | [Link](/Hard/Shorten Path) |
174. | Largest Rectangle Under Skyline | π₯ | Stacks | [Link](/Hard/Largest Rectangle Under Skyline) |
175. | Largest Park | β¬ | Stacks | [Link](/Very Hard/Largest Park) |
176. | Palindrome Check | π© | Strings | [Link](/Easy/Palindrome Check) |
177. | Caesar Cipher Encryptor | π© | Strings | [Link](/Easy/Caesar Cipher Encryptor) |
178. | Run-Length Encoding | π© | Strings | [Link](/Easy/Run-Length Encoding) |
179. | Common Characters | π© | Strings | [Link](/Easy/Common Characters) |
180. | Generate Document | π© | Strings | [Link](/Easy/Generate Document) |
181. | First Non-Repeating Character | π© | Strings | [Link](/Easy/First Non-Repeating Character) |
182. | Semordnilap | π© | Strings | Link |
183. | Longest Palindromic Substring | π¦ | Strings | [Link](/Medium/Longest Palindromic Substring) |
184. | Group Anagrams | π¦ | Strings | [Link](/Medium/Group Anagrams) |
185. | Valid IP Addresses | π¦ | Strings | [Link](/Medium/Valid IP Addresses) |
186. | Reverse Words In String | π¦ | Strings | [Link](/Medium/Reverse Words In String) |
187. | Minimum Characters For Words | π¦ | Strings | [Link](/Medium/Minimum Characters For Words) |
188. | One Edit | π¦ | Strings | [Link](/Medium/One Edit) |
189. | Longest Substring Without Duplication | π₯ | Strings | [Link](/Hard/Longest Substring Without Duplication) |
190. | Underscorify Substring | π₯ | Strings | [Link](/Hard/Underscorify Substring) |
191. | Pattern Matcher | π₯ | Strings | [Link](/Hard/Pattern Matcher) |
192. | Smallest Substring Containing | β¬ | Strings | [Link](/Very Hard/Smallest Substring Containing) |
193. | Longest Balanced Substring | β¬ | Strings | [Link](/Very Hard/Longest Balanced Substring) |
194. | Suffix Trie Construction | π¦ | Tries | [Link](/Medium/Suffix Trie Construction) |
195. | Multi String Search | π₯ | Tries | [Link](/Hard/Multi String Search) |