A curated collection of LeetCode solutions for mastering Data Structures & Algorithms
Built with ❤️ using LeetHub | Track. Solve. Grow.
Each folder is named after the LeetCode problem:
📁 0001-two-sum/
┣ 📄 solution.cpp
┣ 📄 solution.java
┗ 📄 solution.py
Problems are sorted by difficulty and topic (Easy / Medium / Hard).
- 💻 Languages: C++, Java, Python
- 🔁 Sync Tool: LeetHub
- 📚 Platform: LeetCode
# Step 1: Fork this repo
# Step 2: Clone it locally
git clone https://github.com/Anamicca23/Leetcode-for-DSA.git
# Step 3: Add your own solutions following the naming convention📚 Array - Two Pointer, Hash Table
| # | No. | Title | Link | Tags | Level |
|---|---|---|---|---|---|
| 1 | 26 | Remove Duplicates from Sorted Array | Array, Two Pointers | Easy | |
| 2 | 27 | Remove Element | Array, Two Pointers | Easy | |
| 3 | 88 | Merge Sorted Array | Array, Two Pointers, Sorting | Easy | |
| 4 | 170 | Two Sum III - Data Structure Design | Array, Hash Table, Two Pointers | Easy | |
| 5 | 283 | Move Zeroes | Array, Two Pointers | Easy | |
| 6 | 349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers | Easy | |
| 7 | 350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers | Easy | |
| 8 | 455 | Assign Cookies | Array, Two Pointers, Greedy | Easy | |
| 9 | 821 | Shortest Distance to a Character | Array, Two Pointers, String | Easy | |
| 10 | 832 | Flipping an Image | Array, Two Pointers, Matrix | Easy | |
| 11 | 905 | Sort Array By Parity | Array, Two Pointers, Sorting | Easy | |
| 12 | 922 | Sort Array By Parity II | Array, Two Pointers, Sorting | Easy | |
| 13 | 942 | DI String Match | Array, Two Pointers, String | Easy | |
| 14 | 977 | Squares of a Sorted Array | Array, Two Pointers, Sorting | Easy | |
| 15 | 1089 | Duplicate Zeros | Array, Two Pointers | Easy | |
| 16 | 1346 | Check If N and Its Double Exist | Array, Hash Table, Two Pointers | Easy | |
| 17 | 1385 | Find the Distance Value Between Two Arrays | Array, Two Pointers, Binary Search | Easy | |
| 18 | 1826 | Faulty Sensor | Array, Two Pointers | Easy | |
| 19 | 2108 | Find First Palindromic String in the Array | Array, Two Pointers, String | Easy | |
| 20 | 2367 | Number of Arithmetic Triplets | Array, Hash Table, Two Pointers | Easy | |
| 21 | 2441 | Largest Positive Integer That Exists With Its Negative | Array, Hash Table, Two Pointers | Easy | |
| 22 | 2465 | Number of Distinct Averages | Array, Hash Table, Two Pointers | Easy | |
| 23 | 2511 | Maximum Enemy Forts That Can Be Captured | Array, Two Pointers | Easy | |
| 24 | 2540 | Minimum Common Value | Array, Hash Table, Two Pointers | Easy | |
| 25 | 2562 | Find the Array Concatenation Value | Array, Two Pointers, Simulation | Easy | |
| 26 | 2570 | Merge Two 2D Arrays by Summing Values | Array, Hash Table, Two Pointers | Easy |
📚 Array - Sliding Window
| # | No. | Title | Link | Tags | Level |
|---|---|---|---|---|---|
| 1 | 1456 | Maximum Number of Vowels in a Substring of Given Length | String, Sliding Window | Easy | |
| 2 | 1652 | Defuse the Bomb | Array, Sliding Window | Easy | |
| 3 | 1984 | Minimum Difference Between Highest and Lowest of K Scores | Array, Sliding Window, Sorting | Easy | |
| 4 | 2024 | Maximize the Confusion of an Exam | String, Sliding Window, Binary Search | Easy | |
| 5 | 2270 | Number of Ways to Split Array | Array, Sliding Window, Prefix Sum | Easy |
📘 Array - Two Pointer, Sorting, Binary Search, Greedy
| # | No. | Title | LC | Tags | Level |
|---|---|---|---|---|---|
| 1 | 11 | Container With Most Water | Array, Two Pointers, Greedy | Medium | |
| 2 | 15 | 3Sum | Array, Two Pointers, Sorting | Medium | |
| 3 | 16 | 3Sum Closest | Array, Two Pointers, Sorting | Medium | |
| 4 | 18 | 4Sum | Array, Two Pointers, Sorting | Medium | |
| 5 | 31 | Next Permutation | Array, Two Pointers | Medium | |
| 6 | 75 | Sort Colors | Array, Two Pointers, Sorting | Medium | |
| 7 | 80 | Remove Duplicates from Sorted Array II | Array, Two Pointers | Medium | |
| 8 | 167 | Two Sum II - Input Array Is Sorted | Array, Two Pointers, Binary Search | Medium | |
| 9 | 189 | Rotate Array | Array, Math, Two Pointers | Medium | |
| 10 | 244 | Shortest Word Distance II | Array, Hash Table, Two Pointers | Medium | |
| 11 | 251 | Flatten 2D Vector | Array, Two Pointers, Design | Medium | |
| 12 | 253 | Meeting Rooms II | Array, Two Pointers, Greedy | Medium | |
| 13 | 259 | 3Sum Smaller | Array, Two Pointers, Binary Search | Medium | |
| 14 | 287 | Find the Duplicate Number | Array, Two Pointers, Binary Search | Medium | |
| 15 | 360 | Sort Transformed Array | Array, Math, Two Pointers | Medium | |
| 16 | 457 | Circular Array Loop | Array, Hash Table, Two Pointers | Medium | |
| 17 | 475 | Heaters | Array, Two Pointers, Binary Search | Medium | |
| 18 | 522 | Longest Uncommon Subsequence II | Array, Hash Table, Two Pointers | Medium | |
| 19 | 524 | Longest Word in Dictionary through Deleting | Array, Two Pointers, String | Medium | |
| 20 | 532 | K-diff Pairs in an Array | Array, Hash Table, Two Pointers | Medium | |
| 21 | 581 | Shortest Unsorted Continuous Subarray | Array, Two Pointers, Stack | Medium | |
| 22 | 611 | Valid Triangle Number | Array, Two Pointers, Binary Search | Medium | |
| 23 | 658 | Find K Closest Elements | Array, Two Pointers, Binary Search | Medium | |
| 24 | 723 | Candy Crush | Array, Two Pointers, Matrix | Medium | |
| 25 | 795 | Number of Subarrays with Bounded Maximum | Array, Two Pointers | Medium | |
| 26 | 809 | Expressive Words | Array, Two Pointers, String | Medium | |
| 27 | 825 | Friends Of Appropriate Ages | Array, Two Pointers, Binary Search | Medium | |
| 28 | 826 | Most Profit Assigning Work | Array, Two Pointers, Binary Search | Medium | |
| 29 | 845 | Longest Mountain in Array | Array, Two Pointers | Medium | |
| 30 | 870 | Advantage Shuffle | Array, Two Pointers, Greedy | Medium | |
| 31 | 881 | Boats to Save People | Array, Two Pointers, Greedy | Medium | |
| 32 | 923 | 3Sum With Multiplicity | Array, Hash Table, Two Pointers | Medium | |
| 33 | 948 | Bag of Tokens | Array, Two Pointers, Greedy | Medium | |
| 34 | 969 | Pancake Sorting | Array, Two Pointers, Greedy | Medium | |
| 35 | 986 | Interval List Intersections | Array, Two Pointers | Medium | |
| 36 | 1040 | Moving Stones Until Consecutive II | Array, Math, Two Pointers | Medium | |
| 37 | 1048 | Longest String Chain | Array, Hash Table, Two Pointers | Medium | |
| 38 | 1229 | Meeting Scheduler | Array, Two Pointers, Sorting | Medium | |
| 39 | 1471 | The k Strongest Values in an Array | Array, Sorting | Medium | |
| 40 | 1498 | Subsequences Satisfying the Given Sum Condition | Array, Two Pointers, Binary Search | Medium | |
| 41 | 1508 | Range Sum of Sorted Subarray Sums | Array, Two Pointers, Binary Search | Medium | |
| 42 | 1570 | Dot Product of Two Sparse Vectors | Array, Hash Table, Two Pointers | Medium | |
| 43 | 1574 | Shortest Subarray to be Removed to Make Array Sorted | Array, Two Pointers, Binary Search | Medium | |
| 44 | 1577 | Square Equals Product of Two Numbers | Array, Hash Table, Math | Medium | |
| 45 | 1679 | Max Number of K-Sum Pairs | Array, Hash Table, Two Pointers | Medium | |
| 46 | 1712 | Ways to Split Array Into Three Subarrays | Array, Two Pointers, Binary Search | Medium | |
| 47 | 1813 | Sentence Similarity III | Array, Two Pointers, String | Medium | |
| 48 | 1855 | Max Distance Between a Pair of Values | Array, Two Pointers, Binary Search | Medium | |
| 49 | 1861 | Rotating the Box | Array, Two Pointers, Matrix | Medium | |
| 50 | 1868 | Product of Two Run-Length Encoded Arrays | Array, Two Pointers | Medium | |
| 51 | 1877 | Minimize Maximum Pair Sum in Array | Array, Two Pointers, Greedy | Medium | |
| 52 | 2105 | Watering Plants II | Array, Two Pointers, Simulation | Medium | |
| 53 | 2149 | Rearrange Array Elements by Sign | Array, Two Pointers, Simulation | Medium | |
| 54 | 2161 | Partition Array According to Given Pivot | Array, Two Pointers, Simulation | Medium | |
| 55 | 2300 | Successful Pairs of Spells and Potions | Array, Two Pointers, Binary Search | Medium | |
| 56 | 2332 | Latest Time to Catch a Bus | Array, Two Pointers, Binary Search | Medium | |
| 57 | 2406 | Divide Intervals Into Min Number of Groups | Array, Two Pointers, Greedy | Medium | |
| 58 | 2410 | Max Matching of Players With Trainers | Array, Two Pointers, Greedy | Medium | |
| 59 | 2422 | Merge Operations to Turn Array Into Palindrome | Array, Two Pointers, Greedy | Medium | |
| 60 | 2462 | Total Cost to Hire K Workers | Array, Two Pointers | Medium | |
| 61 | 2491 | Divide Players Into Teams of Equal Skill | Array, Hash Table, Two Pointers | Medium | |
| 62 | 2563 | Count the Number of Fair Pairs | Array, Two Pointers, Binary Search | Medium | |
| 63 | 2576 | Max Number of Marked Indices | Array, Two Pointers, Binary Search | Medium | |
| 64 | 2592 | Maximize Greatness of an Array | Array, Two Pointers, Greedy | Medium |
📘 Array - Sliding Window, Binary Search, Hash Table
| # | No. | Title | LC Link | Tags | Level |
|---|---|---|---|---|---|
| 1 | 209 | Minimum Size Subarray Sum | Array, Binary Search, Sliding Window | Medium | |
| 2 | 487 | Max Consecutive Ones II | Array, DP, Sliding Window | Medium | |
| 3 | 658 | Find K Closest Elements | Array, Two Pointers, Binary Search | Medium | |
| 4 | 713 | Subarray Product Less Than K | Array, Sliding Window | Medium | |
| 5 | 718 | Maximum Length of Repeated Subarray | Array, Binary Search | Medium | |
| 6 | 904 | Fruit Into Baskets | Array, Hash Table, Sliding Window | Medium | |
| 7 | 930 | Binary Subarrays With Sum | Array, Hash Table, Sliding Window | Medium | |
| 8 | 978 | Longest Turbulent Subarray | Array, DP, Sliding Window | Medium | |
| 9 | 1004 | Max Consecutive Ones III | Array, Binary Search, Sliding Window | Medium | |
| 10 | 1031 | Max Sum of Two Non-Overlapping Subarrays | Array, DP, Sliding Window | Medium | |
| 11 | 1052 | Grumpy Bookstore Owner | Array, Sliding Window | Medium | |
| 12 | 1151 | Min Swaps to Group All 1's Together | Array, Sliding Window | Medium | |
| 13 | 1248 | Count Number of Nice Subarrays | Array, Hash Table, Math | Medium | |
| 14 | 1343 | Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold | Array, Sliding Window | Medium | |
| 15 | 1423 | Max Points You Can Obtain from Cards | Array, Sliding Window, Prefix Sum | Medium | |
| 16 | 1438 | Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | Array, Queue, Sliding Window | Medium | |
| 17 | 1477 | Two Non-overlapping Subarrays With Target Sum | Array, Hash Table, Binary Search | Medium | |
| 18 | 1493 | Longest Subarray of 1's After Deleting One Element | Array, DP, Sliding Window | Medium | |
| 19 | 1658 | Min Operations to Reduce X to Zero | Array, Hash Table, Binary Search | Medium | |
| 20 | 1695 | Maximum Erasure Value | Array, Hash Table, Sliding Window | Medium | |
| 21 | 1696 | Jump Game VI | Array, DP, Queue | Medium | |
| 22 | 1838 | Frequency of the Most Frequent Element | Array, Binary Search, Greedy | Medium | |
| 23 | 1852 | Distinct Numbers in Each Subarray | Array, Hash Table, Sliding Window | Medium | |
| 24 | 1918 | Kth Smallest Subarray Sum | Array, Binary Search, Sliding Window | Medium | |
| 25 | 2090 | K Radius Subarray Averages | Array, Sliding Window | Medium | |
| 26 | 2107 | Unique Flavors After Sharing K Candies | Array, Hash Table, Sliding Window | Medium | |
| 27 | 2134 | Minimum Swaps to Group All 1's Together II | Array, Sliding Window | Medium | |
| 28 | 2260 | Minimum Consecutive Cards to Pick Up | Array, Hash Table, Sliding Window | Medium | |
| 29 | 2401 | Longest Nice Subarray | Array, Bit Manipulation, Sliding Window | Medium | |
| 30 | 2411 | Smallest Subarrays With Max Bitwise OR | Array, Binary Search, Bit Manipulation | Medium | |
| 31 | 2461 | Maximum Sum of Distinct Subarrays of Length K | Array, Hash Table, Sliding Window | Medium | |
| 32 | 2537 | Count the Number of Good Subarrays | Array, Hash Table, Sliding Window | Medium | |
| 33 | 2555 | Maximize Win From Two Segments | Array, Binary Search, Sliding Window | Medium | |
| 34 | 2653 | Sliding Subarray Beauty | Array, Hash Table, Sliding Window | Medium |
📚 Array - Two Pointer, Binary Search
📚 Array - Sliding Window, Hash Table, Binary Search
📚 Trees and Graphs
📚 BFS / DFS (Shortest Paths)
📚 Hashmaps
📚 Binary Trees
📚 Bitwise Operations
📚 Recursion
📚 Sliding Window (Additional)
📚 Stack
📚 Dynamic Programming
📚 Bitmasking DP
📚 Digit DP
📚 Linked Lists
📚 Suffix and Prefix Array
📚 DSU (Union-Find)
📚 Binary Search (Additional)
📚 Sorting
📚 String
📚 Counting
📚 Line Sweep
📚 Re-rooting
📚 Trie
- Keep filenames clean (
solution.cpp,solution.py) - Add comments where necessary
- Group problems by topics (optional but encouraged)
Want to help expand this repository?
- Fork it 🍴
- Create your feature branch (
git checkout -b new-solution) - Commit your changes (
git commit -m 'Added XYZ problem') - Push to the branch (
git push origin new-solution) - Open a PR 🚀
If this project helps you:
- ⭐ Star the repo
- 🔁 Share it with peers preparing for coding interviews
- 🧠 Keep coding and contribute back!
This project is licensed under the MIT License. See the LICENSE file for details.
Made with ☕ and code by Anamicca23
Let's crack those coding interviews one problem at a time!
| Problem Name | Difficulty |
|---|---|
| 1545-find-kth-bit-in-nth-binary-string | Medium |
| Problem Name | Difficulty |
|---|---|
| 0657-robot-return-to-origin | Easy |
| 0874-walking-robot-simulation | Medium |
| 1545-find-kth-bit-in-nth-binary-string | Medium |
| 1914-cyclically-rotating-a-grid | Medium |
| 2069-walking-robot-simulation-ii | Medium |
| 2075-decode-the-slanted-ciphertext | Medium |
| 2751-robot-collisions | Hard |
| 2946-matrix-similarity-after-cyclic-shifts | Easy |
| 3653-xor-after-range-multiplication-queries-i | Medium |
| Problem Name | Difficulty |
|---|---|
| 1888-minimum-number-of-flips-to-make-the-binary-string-alternating | Medium |
| Problem Name | Difficulty |
|---|---|
| 1415-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n | Medium |
| 1980-find-unique-binary-string | Medium |
| Problem Name | Difficulty |
|---|---|
| 1009-complement-of-base-10-integer | Easy |
| Problem Name | Difficulty |
|---|---|
| 1559-detect-cycles-in-2d-grid | Medium |
| 1722-minimize-hamming-distance-after-swap-operations | Medium |
| 2573-find-the-string-with-lcp | Hard |
| 3600-maximize-spanning-tree-stability-with-upgrades | Hard |
| Problem Name | Difficulty |
|---|---|
| 3600-maximize-spanning-tree-stability-with-upgrades | Hard |
| Problem Name | Difficulty |
|---|---|
| 3600-maximize-spanning-tree-stability-with-upgrades | Hard |
| Problem Name | Difficulty |
|---|---|
| 1878-get-biggest-three-rhombus-sums-in-a-grid | Medium |
| 3296-minimum-number-of-seconds-to-make-mountain-height-zero | Medium |
| Problem Name | Difficulty |
|---|---|
| 1622-fancy-sequence | Hard |
| 2069-walking-robot-simulation-ii | Medium |
| Problem Name | Difficulty |
|---|---|
| 1622-fancy-sequence | Hard |
| Problem Name | Difficulty |
|---|---|
| 0061-rotate-list | Medium |
| 1855-maximum-distance-between-a-pair-of-values | Medium |
| 1861-rotating-the-box | Medium |
| 3643-flip-square-submatrix-vertically | Easy |
| Problem Name | Difficulty |
|---|---|
| 3546-equal-sum-grid-partition-i | Medium |
| 3548-equal-sum-grid-partition-ii | Hard |
| Problem Name | Difficulty |
|---|---|
| 0796-rotate-string | Easy |
| 3474-lexicographically-smallest-generated-string | Hard |
| Problem Name | Difficulty |
|---|---|
| 2751-robot-collisions | Hard |
| Problem Name | Difficulty |
|---|---|
| 3653-xor-after-range-multiplication-queries-i | Medium |
| 3655-xor-after-range-multiplication-queries-ii | Hard |
| Problem Name | Difficulty |
|---|---|
| 1559-detect-cycles-in-2d-grid | Medium |
| 1722-minimize-hamming-distance-after-swap-operations | Medium |
| Problem Name | Difficulty |
|---|---|
| 2452-words-within-two-edits-of-dictionary | Medium |
| Problem Name | Difficulty |
|---|---|
| 2833-furthest-point-from-origin | Easy |
| Problem Name | Difficulty |
|---|---|
| 3464-maximize-the-distance-between-points-on-a-square | Hard |
| Problem Name | Difficulty |
|---|---|
| 1559-detect-cycles-in-2d-grid | Medium |
| 3629-minimum-jumps-to-reach-end-via-prime-teleportation | Medium |
| Problem Name | Difficulty |
|---|---|
| 0061-rotate-list | Medium |
| Problem Name | Difficulty |
|---|---|
| 3629-minimum-jumps-to-reach-end-via-prime-teleportation | Medium |