#test 6
This repository contains clean, modular, and time/space optimal solutions for all 150 problems from the standard NeetCode 150 roadmap, implemented in both C (C99/C11) and modern C++ (C++17/20).
Every problem folder contains:
solution.cβ Memory-efficient, standard C implementation.solution.cppβ Modern, idiomatic C++ with STL containers (vector,unordered_map,priority_queue, etc.).README.mdβ LeetCode reference, complexity analysis, and approach explanation.
| # | Topic | Problems | Status |
|---|---|---|---|
| 1 | Arrays & Hashing | 9 | β Completed |
| 2 | Two Pointers | 5 | β Completed |
| 3 | Sliding Window | 6 | β Completed |
| 4 | Stack | 7 | β Completed |
| 5 | Binary Search | 7 | β Completed |
| 6 | Linked List | 11 | β Completed |
| 7 | Trees | 15 | β Completed |
| 8 | Tries | 3 | β Completed |
| 9 | Heap / Priority Queue | 7 | β Completed |
| 10 | Backtracking | 9 | β Completed |
| 11 | Graphs | 13 | β Completed |
| 12 | Advanced Graphs | 6 | β Completed |
| 13 | 1-D Dynamic Programming | 12 | β Completed |
| 14 | 2-D Dynamic Programming | 11 | β Completed |
| 15 | Greedy | 8 | β Completed |
| 16 | Intervals | 6 | β Completed |
| 17 | Math & Geometry | 8 | β Completed |
| 18 | Bit Manipulation | 7 | β Completed |
| TOTAL | 150 / 150 | 100% COMPLETE |
| # | Topic | Problem | LeetCode | Difficulty | C Solution | C++ Solution | Time | Space |
|---|---|---|---|---|---|---|---|---|
| 1 | Arrays & Hashing | Contains Duplicate | #217 | π’ Easy | C | C++ | O(n) |
O(n) |
| 2 | Arrays & Hashing | Valid Anagram | #242 | π’ Easy | C | C++ | O(n) |
O(1) |
| 3 | Arrays & Hashing | Two Sum | #1 | π’ Easy | C | C++ | O(n) |
O(n) |
| 4 | Arrays & Hashing | Group Anagrams | #49 | π‘ Medium | C | C++ | O(n * k log k) |
O(n * k) |
| 5 | Arrays & Hashing | Top K Frequent Elements | #347 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 6 | Arrays & Hashing | Product of Array Except Self | #238 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 7 | Arrays & Hashing | Valid Sudoku | #36 | π‘ Medium | C | C++ | O(1) |
O(1) |
| 8 | Arrays & Hashing | Encode and Decode Strings | #271 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 9 | Arrays & Hashing | Longest Consecutive Sequence | #128 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 10 | Two Pointers | Valid Palindrome | #125 | π’ Easy | C | C++ | O(n) |
O(1) |
| 11 | Two Pointers | Two Sum II - Input Array Is Sorted | #167 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 12 | Two Pointers | 3Sum | #15 | π‘ Medium | C | C++ | O(n^2) |
O(1) auxiliary |
| 13 | Two Pointers | Container With Most Water | #11 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 14 | Two Pointers | Trapping Rain Water | #42 | π΄ Hard | C | C++ | O(n) |
O(1) |
| 15 | Sliding Window | Best Time to Buy and Sell Stock | #121 | π’ Easy | C | C++ | O(n) |
O(1) |
| 16 | Sliding Window | Longest Substring Without Repeating Characters | #3 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 17 | Sliding Window | Longest Repeating Character Replacement | #424 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 18 | Sliding Window | Permutation in String | #567 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 19 | Sliding Window | Minimum Window Substring | #76 | π΄ Hard | C | C++ | O(n + m) |
O(1) |
| 20 | Sliding Window | Sliding Window Maximum | #239 | π΄ Hard | C | C++ | O(n) |
O(k) |
| 21 | Stack | Valid Parentheses | #20 | π’ Easy | C | C++ | O(n) |
O(n) |
| 22 | Stack | Min Stack | #155 | π‘ Medium | C | C++ | O(1) all ops |
O(n) |
| 23 | Stack | Evaluate Reverse Polish Notation | #150 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 24 | Stack | Generate Parentheses | #22 | π‘ Medium | C | C++ | O(4^n / sqrt(n)) |
O(n) |
| 25 | Stack | Daily Temperatures | #739 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 26 | Stack | Car Fleet | #853 | π‘ Medium | C | C++ | O(n log n) |
O(n) |
| 27 | Stack | Largest Rectangle in Histogram | #84 | π΄ Hard | C | C++ | O(n) |
O(n) |
| 28 | Binary Search | Binary Search | #704 | π’ Easy | C | C++ | O(log n) |
O(1) |
| 29 | Binary Search | Search a 2D Matrix | #74 | π‘ Medium | C | C++ | O(log(m * n)) |
O(1) |
| 30 | Binary Search | Koko Eating Bananas | #875 | π‘ Medium | C | C++ | O(n log(max(P))) |
O(1) |
| 31 | Binary Search | Find Minimum in Rotated Sorted Array | #153 | π‘ Medium | C | C++ | O(log n) |
O(1) |
| 32 | Binary Search | Search in Rotated Sorted Array | #33 | π‘ Medium | C | C++ | O(log n) |
O(1) |
| 33 | Binary Search | Time Based Key-Value Store | #981 | π‘ Medium | C | C++ | Set: O(1), Get: O(log n) |
O(n) |
| 34 | Binary Search | Median of Two Sorted Arrays | #4 | π΄ Hard | C | C++ | O(log(min(m, n))) |
O(1) |
| 35 | Linked List | Reverse Linked List | #206 | π’ Easy | C | C++ | O(n) |
O(1) |
| 36 | Linked List | Merge Two Sorted Lists | #21 | π’ Easy | C | C++ | O(n + m) |
O(1) |
| 37 | Linked List | Reorder List | #143 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 38 | Linked List | Remove Nth Node From End of List | #19 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 39 | Linked List | Copy List with Random Pointer | #138 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 40 | Linked List | Add Two Numbers | #2 | π‘ Medium | C | C++ | O(max(m, n)) |
O(1) |
| 41 | Linked List | Linked List Cycle | #141 | π’ Easy | C | C++ | O(n) |
O(1) |
| 42 | Linked List | Find the Duplicate Number | #287 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 43 | Linked List | LRU Cache | #146 | π‘ Medium | C | C++ | O(1) get & put |
O(capacity) |
| 44 | Linked List | Merge K Sorted Lists | #23 | π΄ Hard | C | C++ | O(n log k) |
O(k) |
| 45 | Linked List | Reverse Nodes in k-Group | #25 | π΄ Hard | C | C++ | O(n) |
O(1) |
| 46 | Trees | Invert Binary Tree | #226 | π’ Easy | C | C++ | O(n) |
O(h) |
| 47 | Trees | Maximum Depth of Binary Tree | #104 | π’ Easy | C | C++ | O(n) |
O(h) |
| 48 | Trees | Diameter of Binary Tree | #543 | π’ Easy | C | C++ | O(n) |
O(h) |
| 49 | Trees | Balanced Binary Tree | #110 | π’ Easy | C | C++ | O(n) |
O(h) |
| 50 | Trees | Same Tree | #100 | π’ Easy | C | C++ | O(n) |
O(h) |
| 51 | Trees | Subtree of Another Tree | #572 | π’ Easy | C | C++ | O(s * t) |
O(h) |
| 52 | Trees | Lowest Common Ancestor of a BST | #235 | π‘ Medium | C | C++ | O(h) |
O(1) |
| 53 | Trees | Binary Tree Level Order Traversal | #102 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 54 | Trees | Binary Tree Right Side View | #199 | π‘ Medium | C | C++ | O(n) |
O(h) |
| 55 | Trees | Count Good Nodes in Binary Tree | #1448 | π‘ Medium | C | C++ | O(n) |
O(h) |
| 56 | Trees | Validate Binary Search Tree | #98 | π‘ Medium | C | C++ | O(n) |
O(h) |
| 57 | Trees | Kth Smallest Element in a BST | #230 | π‘ Medium | C | C++ | O(h + k) |
O(h) |
| 58 | Trees | Construct Binary Tree from Preorder and Inorder Traversal | #105 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 59 | Trees | Binary Tree Maximum Path Sum | #124 | π΄ Hard | C | C++ | O(n) |
O(h) |
| 60 | Trees | Serialize and Deserialize Binary Tree | #297 | π΄ Hard | C | C++ | O(n) |
O(n) |
| 61 | Tries | Implement Trie (Prefix Tree) | #208 | π‘ Medium | C | C++ | O(L) per op |
O(total characters) |
| 62 | Tries | Design Add and Search Words Data Structure | #211 | π‘ Medium | C | C++ | Add: O(L), Search: O(26^d) |
O(total chars) |
| 63 | Tries | Word Search II | #212 | π΄ Hard | C | C++ | O(m * n * 4^L) |
O(total characters in words) |
| 64 | Heap / Priority Queue | Kth Largest Element in a Stream | #703 | π’ Easy | C | C++ | O(n log k) |
O(k) |
| 65 | Heap / Priority Queue | Last Stone Weight | #1046 | π’ Easy | C | C++ | O(n log n) |
O(n) |
| 66 | Heap / Priority Queue | K Closest Points to Origin | #973 | π‘ Medium | C | C++ | O(n log k) |
O(k) |
| 67 | Heap / Priority Queue | Kth Largest Element in an Array | #215 | π‘ Medium | C | C++ | O(n) average QuickSelect or O(n log k) Min-Heap |
O(1) |
| 68 | Heap / Priority Queue | Task Scheduler | #621 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 69 | Heap / Priority Queue | Design Twitter | #355 | π‘ Medium | C | C++ | O(k log k) |
O(users + tweets) |
| 70 | Heap / Priority Queue | Find Median from Data Stream | #295 | π΄ Hard | C | C++ | Add: O(log n), Find: O(1) |
O(n) |
| 71 | Backtracking | Subsets | #78 | π‘ Medium | C | C++ | O(n * 2^n) |
O(n) |
| 72 | Backtracking | Combination Sum | #39 | π‘ Medium | C | C++ | O(2^target) |
O(target) |
| 73 | Backtracking | Permutations | #46 | π‘ Medium | C | C++ | O(n! * n) |
O(n) |
| 74 | Backtracking | Subsets II | #90 | π‘ Medium | C | C++ | O(n * 2^n) |
O(n) |
| 75 | Backtracking | Combination Sum II | #40 | π‘ Medium | C | C++ | O(2^n) |
O(n) |
| 76 | Backtracking | Word Search | #79 | π‘ Medium | C | C++ | O(m * n * 4^L) |
O(L) |
| 77 | Backtracking | Palindrome Partitioning | #131 | π‘ Medium | C | C++ | O(n * 2^n) |
O(n) |
| 78 | Backtracking | Letter Combinations of a Phone Number | #17 | π‘ Medium | C | C++ | O(4^n * n) |
O(n) |
| 79 | Backtracking | N-Queens | #51 | π΄ Hard | C | C++ | O(n!) |
O(n) |
| 80 | Graphs | Number of Islands | #200 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 81 | Graphs | Clone Graph | #133 | π‘ Medium | C | C++ | O(V + E) |
O(V) |
| 82 | Graphs | Max Area of Island | #695 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 83 | Graphs | Pacific Atlantic Water Flow | #417 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 84 | Graphs | Surrounded Regions | #130 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 85 | Graphs | Rotting Oranges | #994 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 86 | Graphs | Walls and Gates | #286 | π‘ Medium | C | C++ | O(m * n) |
O(m * n) |
| 87 | Graphs | Course Schedule | #207 | π‘ Medium | C | C++ | O(V + E) |
O(V + E) |
| 88 | Graphs | Course Schedule II | #210 | π‘ Medium | C | C++ | O(V + E) |
O(V + E) |
| 89 | Graphs | Redundant Connection | #684 | π‘ Medium | C | C++ | O(n * alpha(n)) |
O(n) |
| 90 | Graphs | Number of Connected Components in an Undirected Graph | #323 | π‘ Medium | C | C++ | O(V + E) |
O(V) |
| 91 | Graphs | Graph Valid Tree | #261 | π‘ Medium | C | C++ | O(V + E) |
O(V) |
| 92 | Graphs | Word Ladder | #127 | π΄ Hard | C | C++ | O(M^2 * N) |
O(M^2 * N) |
| 93 | Advanced Graphs | Reconstruct Itinerary | #332 | π΄ Hard | C | C++ | O(E log E) |
O(V + E) |
| 94 | Advanced Graphs | Min Cost to Connect All Points | #1584 | π‘ Medium | C | C++ | O(V^2) |
O(V) |
| 95 | Advanced Graphs | Network Delay Time | #743 | π‘ Medium | C | C++ | O(E log V) |
O(V + E) |
| 96 | Advanced Graphs | Swim in Rising Water | #778 | π΄ Hard | C | C++ | O(n^2 log n) |
O(n^2) |
| 97 | Advanced Graphs | Alien Dictionary | #269 | π΄ Hard | C | C++ | O(C) |
O(1) |
| 98 | Advanced Graphs | Cheapest Flights Within K Stops | #787 | π‘ Medium | C | C++ | O(K * E) |
O(V) |
| 99 | 1-D Dynamic Programming | Climbing Stairs | #70 | π’ Easy | C | C++ | O(n) |
O(1) |
| 100 | 1-D Dynamic Programming | Min Cost Climbing Stairs | #746 | π’ Easy | C | C++ | O(n) |
O(1) |
| 101 | 1-D Dynamic Programming | House Robber | #198 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 102 | 1-D Dynamic Programming | House Robber II | #213 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 103 | 1-D Dynamic Programming | Longest Palindromic Substring | #5 | π‘ Medium | C | C++ | O(n^2) |
O(1) |
| 104 | 1-D Dynamic Programming | Palindromic Substrings | #647 | π‘ Medium | C | C++ | O(n^2) |
O(1) |
| 105 | 1-D Dynamic Programming | Decode Ways | #91 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 106 | 1-D Dynamic Programming | Coin Change | #322 | π‘ Medium | C | C++ | O(amount * n) |
O(amount) |
| 107 | 1-D Dynamic Programming | Maximum Product Subarray | #152 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 108 | 1-D Dynamic Programming | Word Break | #139 | π‘ Medium | C | C++ | O(n * m * k) |
O(n) |
| 109 | 1-D Dynamic Programming | Longest Increasing Subsequence | #300 | π‘ Medium | C | C++ | O(n log n) |
O(n) |
| 110 | 1-D Dynamic Programming | Partition Equal Subset Sum | #416 | π‘ Medium | C | C++ | O(n * sum) |
O(sum) |
| 111 | 2-D Dynamic Programming | Unique Paths | #62 | π‘ Medium | C | C++ | O(m * n) |
O(n) |
| 112 | 2-D Dynamic Programming | Longest Common Subsequence | #1143 | π‘ Medium | C | C++ | O(m * n) |
O(min(m, n)) |
| 113 | 2-D Dynamic Programming | Best Time to Buy and Sell Stock with Cooldown | #309 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 114 | 2-D Dynamic Programming | Coin Change II | #518 | π‘ Medium | C | C++ | O(amount * n) |
O(amount) |
| 115 | 2-D Dynamic Programming | Target Sum | #494 | π‘ Medium | C | C++ | O(n * sum) |
O(sum) |
| 116 | 2-D Dynamic Programming | Interleaving String | #97 | π‘ Medium | C | C++ | O(m * n) |
O(n) |
| 117 | 2-D Dynamic Programming | Longest Increasing Path in a Matrix | #329 | π΄ Hard | C | C++ | O(m * n) |
O(m * n) |
| 118 | 2-D Dynamic Programming | Distinct Subsequences | #115 | π΄ Hard | C | C++ | O(m * n) |
O(n) |
| 119 | 2-D Dynamic Programming | Edit Distance | #72 | π‘ Medium | C | C++ | O(m * n) |
O(n) |
| 120 | 2-D Dynamic Programming | Burst Balloons | #312 | π΄ Hard | C | C++ | O(n^3) |
O(n^2) |
| 121 | 2-D Dynamic Programming | Regular Expression Matching | #10 | π΄ Hard | C | C++ | O(m * n) |
O(m * n) |
| 122 | Greedy | Maximum Subarray | #53 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 123 | Greedy | Jump Game | #55 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 124 | Greedy | Jump Game II | #45 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 125 | Greedy | Gas Station | #134 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 126 | Greedy | Hand of Straights | #846 | π‘ Medium | C | C++ | O(n log n) |
O(n) |
| 127 | Greedy | Merge Triplets to Form Target Triplet | #1899 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 128 | Greedy | Partition Labels | #763 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 129 | Greedy | Valid Parenthesis String | #678 | π‘ Medium | C | C++ | O(n) |
O(1) |
| 130 | Intervals | Insert Interval | #57 | π‘ Medium | C | C++ | O(n) |
O(n) |
| 131 | Intervals | Merge Intervals | #56 | π‘ Medium | C | C++ | O(n log n) |
O(n) |
| 132 | Intervals | Non-overlapping Intervals | #435 | π‘ Medium | C | C++ | O(n log n) |
O(1) |
| 133 | Intervals | Meeting Rooms | #252 | π’ Easy | C | C++ | O(n log n) |
O(1) |
| 134 | Intervals | Meeting Rooms II | #253 | π‘ Medium | C | C++ | O(n log n) |
O(n) |
| 135 | Intervals | Minimum Interval to Include Each Query | #1851 | π΄ Hard | C | C++ | O(n log n + q log q) |
O(n + q) |
| 136 | Math & Geometry | Rotate Image | #48 | π‘ Medium | C | C++ | O(n^2) |
O(1) |
| 137 | Math & Geometry | Spiral Matrix | #54 | π‘ Medium | C | C++ | O(m * n) |
O(1) auxiliary |
| 138 | Math & Geometry | Set Matrix Zeroes | #73 | π‘ Medium | C | C++ | O(m * n) |
O(1) |
| 139 | Math & Geometry | Happy Number | #202 | π’ Easy | C | C++ | O(log n) |
O(1) |
| 140 | Math & Geometry | Plus One | #66 | π’ Easy | C | C++ | O(n) |
O(1) auxiliary |
| 141 | Math & Geometry | Pow(x, n) | #50 | π‘ Medium | C | C++ | O(log n) |
O(1) |
| 142 | Math & Geometry | Multiply Strings | #43 | π‘ Medium | C | C++ | O(m * n) |
O(m + n) |
| 143 | Math & Geometry | Detect Squares | #2013 | π‘ Medium | C | C++ | Add: O(1), Count: O(N) |
O(N) |
| 144 | Bit Manipulation | Single Number | #136 | π’ Easy | C | C++ | O(n) |
O(1) |
| 145 | Bit Manipulation | Number of 1 Bits | #191 | π’ Easy | C | C++ | O(1) |
O(1) |
| 146 | Bit Manipulation | Counting Bits | #338 | π’ Easy | C | C++ | O(n) |
O(1) auxiliary |
| 147 | Bit Manipulation | Reverse Bits | #190 | π’ Easy | C | C++ | O(1) |
O(1) |
| 148 | Bit Manipulation | Missing Number | #268 | π’ Easy | C | C++ | O(n) |
O(1) |
| 149 | Bit Manipulation | Sum of Two Integers | #371 | π‘ Medium | C | C++ | O(1) |
O(1) |
| 150 | Bit Manipulation | Reverse Integer | #7 | π‘ Medium | C | C++ | O(log x) |
O(1) |
# Compile with GCC
gcc -Wall -Wextra -O2 01-Arrays-and-Hashing/01-contains-duplicate/solution.c -o solution
./solution# Compile with G++ (C++17)
g++ -std=c++17 -Wall -Wextra -O2 01-Arrays-and-Hashing/01-contains-duplicate/solution.cpp -o solution
./solution- Md Rakibul Islam (Baadal)
- GitHub: @baadaldev
- LeetCode: @Baadal89131
- LinkedIn: Md Rakibul Islam
This project is licensed under the MIT License.
π Note: All problem solutions include comprehensive Big-O time and space complexity analysis.