Skip to content

This repository contains solution to AlgoExpert problem, in C++ and Python

Notifications You must be signed in to change notification settings

AyushiGarg13/algoexpert-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AlgoExpert Solutions

Soltuions to AlgoExpert Problems in C++ and Python with their optimal Space-Time Complexities.

List of Problems

Categories

  • Arrays
  • Binary Search Trees
  • Binary Trees
  • Dynamic Programming
  • Famous Algorithms
  • Graphs
  • Greedy Algorithms
  • Heaps
  • Linked Lists
  • Recursion
  • Searching
  • Sorting
  • Stacks
  • Strings
  • Tries

Difficulty Levels

  • 🟩 - Easy
  • 🟦 - Medium
  • πŸŸ₯ - Hard
  • ⬛ - Very Hard

Problems & Soltuions

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)

About

This repository contains solution to AlgoExpert problem, in C++ and Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published