An optimized archive of Data Structures and Algorithms solutions from leetCode, GeeksforGeeks and other competitive platform, aiming for clean and efficient code. Welcome to my coding archive! Here I document my journey of mastering Data Structures and Algorithms.
| # | Problem Name | Solution | Topic | Time Complexity | Difficulty |
|---|---|---|---|---|---|
| 1 | Two Sum | Code | Arrays / Hashmap | O(n) |
🟢 Easy |
| 2 | Palindrome Number | Code | Math | O(log n) |
🟢 Easy |
| 3 | Fibonacci Number | Code | Math / DP | O(n) |
🟢 Easy |
| 4 | Remove Duplicates | Code | Arrays / Two Pointers | O(n) |
🟢 Easy |
| 5 | Rotate Array | Code | Arrays | O(2n) |
🟡 Medium |
| 6 | Move Zeroes | Code | Arrays | O(n) |
🟢 Easy |
| 7 | Missing Number | Code | Math | O(n) |
🟢 Easy |
| 8 | Max Consecutive Ones | Code | Arrays | O(n) |
🟡 Medium |
| 9 | Single Number | Code | Arrays | O(n) |
🟢 Easy |
| 10 | Sort Colors | Code | Arrays / Two pointers | O(n) |
🟡 Medium |
| 11 | Majority Element | Code | Arrays | O(n) |
🟡 Medium |
| 12 | Maximum Subarray | Code | Arrays | O(n) |
🟡 Medium |
| 13 | Rearrange Array | Code | Arrays / Two pointers | O(n) |
🟡 Medium |
| 14 | Binary Search | Code | Binary Search | O(log n) |
🟢 Easy |
| 15 | Search Insert | Code | Binary Search | O(log n) |
🟢 Easy |
| 16 | Rotated Search | Code | Binary Search | O(log n) |
🟡 Medium |
| 17 | Rotated Minimum | Code | Binary Search | O(log n) |
🔴 Hard |
| 18 | Single Element | Code | Binary Search | O(log n) |
🟡 Medium |
| 19 | Koko Eating Bananas | Code | Binary Search | O(N⋅log(max(piles))) |
🔴 Hard |
| 20 | Minimum Days for Bouquets | Code | Binary Search | O(N logD) |
🟡 Medium |
| 21 | Capacity to Ship Packages | Code | Binary Search | O(N logS) |
🟡 Medium |
| 22 | Split Array largest Sum | Code | Binary Search | O(nlog(sum of array)) |
🔴 Hard |
| 23 | Aggressive Cows | Code | Binary Search | O(nlogM) |
🔴 Hard |
| 24 | Book Allocation | Code | Binary Search | O(nlog(sum of pages)) |
🔴 Hard |
| 25 | Smallest Divisor | Code | Binary Search | O(nlog(maxelement)) |
🟡 Medium |
| 26 | Maximum Points | Code | Sliding window | O(N) |
🟡 Medium |
| 27 | Longest substring | Code | Sliding window | O(N) |
🟡 Medium |
| 28 | Max Consecutive Ones | Code | Sliding window | O(N) |
🟡 Medium |
| 29 | Delete Node | Code | Linked List | O(1) |
🟢 Easy |
| 30 | Remove Elements | Code | Linked List | O(n) |
🟡 Medium |
To compile and run any solution (e.g., TwoSum):
g++ Arrays/TwoSum.cpp -o solution
./solution''