https://github.com/aliataf/leetcode-solutions
📚 LeetCode solutions in C++ with detailed explanations and complexity analysis
https://github.com/aliataf/leetcode-solutions
cplusplus leetcode problem-solving
Last synced: 11 days ago
JSON representation
📚 LeetCode solutions in C++ with detailed explanations and complexity analysis
- Host: GitHub
- URL: https://github.com/aliataf/leetcode-solutions
- Owner: aliataf
- Created: 2025-11-25T20:26:16.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-12-18T21:50:51.000Z (17 days ago)
- Last Synced: 2025-12-21T22:29:02.526Z (14 days ago)
- Topics: cplusplus, leetcode, problem-solving
- Language: C++
- Homepage: https://leetcode.com/u/aliataf/
- Size: 150 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🧠 LeetCode Solutions
[](https://leetcode.com/)
[](https://isocpp.org/)
My solutions to LeetCode problems, organized by topic and difficulty. Each solution includes detailed explanations, time & space complexity analysis, and multiple approaches when applicable.
## 📊 Progress
| Difficulty | Solved |
|------------|--------|
| 🟢 Easy | 24 |
| 🟡 Medium | 29 |
| 🔴 Hard | 5 |
| **Total** | **58** |
## 📁 Repository Structure
```
leetcode-solutions/
├── arrays/
├── backtracking/
├── binary-search/
├── dynamic-programming/
├── graphs/
├── greedy/
├── heap/
├── linked-lists/
├── math/
├── misc/
├── sliding-window/
├── stack-queue/
├── strings/
├── trees/
└── two-pointers/
```
## 🗂️ Solutions by Topic
### Arrays
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/) | 🟢 Easy | [C++](arrays/0001_two_sum.cpp) |
| 15 | [3Sum](https://leetcode.com/problems/3sum/) | 🟡 Medium | [C++](arrays/0015_3sum.cpp) |
| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | 🟢 Easy | [C++](arrays/0026_remove_duplicates_from_sorted_array.cpp) |
| 27 | [Remove Element](https://leetcode.com/problems/remove-element/) | 🟢 Easy | [C++](arrays/0027_remove_element.cpp) |
| 36 | [Valid Sudoku](https://leetcode.com/problems/valid-sudoku/) | 🟡 Medium | [C++](arrays/0036_valid_sudoku.cpp) |
| 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix/) | 🟡 Medium | [C++](arrays/0054_spiral_matrix.cpp) |
| 88 | [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/) | 🟢 Easy | [C++](arrays/0088_merge_sorted_array.cpp) |
| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/) | 🟡 Medium | [C++](arrays/0128_longest_consecutive_sequence.cpp) |
| 1991 | [Find the Middle Index in Array](https://leetcode.com/problems/find-the-middle-index-in-array/) | 🟢 Easy | [C++](arrays/1991_find_the_middle_index_in_array.cpp) |
### Backtracking
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 17 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/) | 🟡 Medium | [C++](backtracking/0017_letter_combinations_of_a_phone_number.cpp) |
| 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses/) | 🟡 Medium | [C++](backtracking/0022_generate_parentheses.cpp) |
### Binary Search
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | � Hard | [C++](binary-search/0004_median_of_two_sorted_arrays.cpp) |
| 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | � Easy | [C++](binary-search/0035_search_insert_position.cpp) |
| 74 | [Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix/) | � Medium | [C++](binary-search/0074_search_a_2d_matrix.cpp) |
### Dynamic Programming
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 10 | [Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching/) | 🔴 Hard | [C++](dynamic-programming/0010_regular_expression_matching.cpp) |
| 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/) | 🟡 Medium | [C++](dynamic-programming/0005_longest_palindromic_substring.cpp) |
| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths/) | � Medium | [C++](dynamic-programming/0062_unique_paths.cpp) |
| 63 | [Unique Paths II](https://leetcode.com/problems/unique-paths-ii/) | � Medium | [C++](dynamic-programming/0063_unique_paths_ii.cpp) |
| 64 | [Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum/) | � Medium | [C++](dynamic-programming/0064_minimum_path_sum.cpp) |
| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/) | 🟢 Easy | [C++](dynamic-programming/0070_climbing_stairs.cpp) |
| 72 | [Edit Distance](https://leetcode.com/problems/edit-distance/) | � Medium | [C++](dynamic-programming/0072_edit_distance.cpp) |
| 118 | [Pascal's Triangle](https://leetcode.com/problems/pascals-triangle/) | 🟢 Easy | [C++](dynamic-programming/0118_pascals_triangle.cpp) |
| 119 | [Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii/) | 🟢 Easy | [C++](dynamic-programming/0119_pascals_triangle_ii.cpp) |
| 139 | [Word Break](https://leetcode.com/problems/word-break/) | 🟡 Medium | [C++](dynamic-programming/0139_word_break.cpp) |
### Graphs
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 133 | [Clone Graph](https://leetcode.com/problems/clone-graph/) | 🟡 Medium | [C++](graphs/0133_clone_graph.cpp) |
| 207 | [Course Schedule](https://leetcode.com/problems/course-schedule/) | 🟡 Medium | [C++](graphs/0207_course_schedule.cpp) |
| 210 | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii/) | 🟡 Medium | [C++](graphs/0210_course_schedule_ii.cpp) |
| 997 | [Find the Town Judge](https://leetcode.com/problems/find-the-town-judge/) | 🟢 Easy | [C++](graphs/0997_find_the_town_judge.cpp) |
### Greedy
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii/) | 🟡 Medium | [C++](greedy/0045_jump_game_ii.cpp) |
| 55 | [Jump Game](https://leetcode.com/problems/jump-game/) | 🟡 Medium | [C++](greedy/0055_jump_game.cpp) |
| 121 | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) | � Easy | [C++](greedy/0121_best_time_to_buy_and_sell_stock.cpp) |
| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) | 🟡 Medium | [C++](greedy/0122_best_time_to_buy_and_sell_stock_ii.cpp) |
### Heap / Priority Queue
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| - | - | - | - |
### Linked Lists
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers/) | 🟡 Medium | [C++](linked-lists/0002_add_two_numbers.cpp) |
| 21 | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/) | 🟢 Easy | [C++](linked-lists/0021_merge_two_sorted_lists.cpp) |
| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) | 🟢 Easy | [C++](linked-lists/0083_remove_duplicates_from_sorted_list.cpp) |
| 141 | [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/) | � Easy | [C++](linked-lists/0141_linked_list_cycle.cpp) |
### Math
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer/) | � Medium | [C++](math/0007_reverse_integer.cpp) |
| 9 | [Palindrome Number](https://leetcode.com/problems/palindrome-number/) | 🟢 Easy | [C++](math/0009_palindrome_number.cpp) |
| 12 | [Integer to Roman](https://leetcode.com/problems/integer-to-roman/) | 🟡 Medium | [C++](math/0012_integer_to_roman.cpp) |
| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer/) | 🟢 Easy | [C++](math/0013_roman_to_integer.cpp) |
| 66 | [Plus One](https://leetcode.com/problems/plus-one/) | 🟢 Easy | [C++](math/0066_plus_one.cpp) |
| 67 | [Add Binary](https://leetcode.com/problems/add-binary/) | � Easy | [C++](math/0067_add_binary.cpp) |
| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx/) | 🟢 Easy | [C++](math/0069_sqrt_x.cpp) |
| 136 | [Single Number](https://leetcode.com/problems/single-number/) | � Easy | [C++](math/0136_single_number.cpp) |
| 137 | [Single Number II](https://leetcode.com/problems/single-number-ii/) | � Medium | [C++](math/0137_single_number_ii.cpp) |
### Sliding Window
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | 🟡 Medium | [C++](sliding-window/0003_longest_substring_without_repeating_characters.cpp) |
| 76 | [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/) | 🔴 Hard | [C++](sliding-window/0076_minimum_window_substring.cpp) |
### Stack & Queue
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses/) | 🟢 Easy | [C++](stack-queue/0020_valid_parentheses.cpp) |
| 84 | [Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/) | 🔴 Hard | [C++](stack-queue/0084_largest_rectangle_in_histogram.cpp) |
### Strings
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 6 | [Zigzag Conversion](https://leetcode.com/problems/zigzag-conversion/) | 🟡 Medium | [C++](strings/0006_zigzag_conversion.cpp) |
| 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) | 🟡 Medium | [C++](strings/0008_string_to_integer_atoi.cpp) |
| 14 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | � Easy | [C++](strings/0014_longest_common_prefix.cpp) |
| 28 | [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/) | � Easy | [C++](strings/0028_find_index_of_first_occurrence.cpp) |
| 49 | [Group Anagrams](https://leetcode.com/problems/group-anagrams/) | � Medium | [C++](strings/0049_group_anagrams.cpp) |
| 58 | [Length of Last Word](https://leetcode.com/problems/length-of-last-word/) | � Easy | [C++](strings/0058_length_of_last_word.cpp) |
### Trees
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal/) | � Easy | [C++](trees/0094_binary_tree_inorder_traversal.cpp) |
| 100 | [Same Tree](https://leetcode.com/problems/same-tree/) | 🟢 Easy | [C++](trees/0100_same_tree.cpp) |
| 112 | [Path Sum](https://leetcode.com/problems/path-sum/) | 🟢 Easy | [C++](trees/0112_path_sum.cpp) |
| 113 | [Path Sum II](https://leetcode.com/problems/path-sum-ii/) | 🟡 Medium | [C++](trees/0113_path_sum_ii.cpp) |
### Two Pointers
| # | Title | Difficulty | Solution |
|---|-------|------------|----------|
| 11 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water/) | 🟡 Medium | [C++](two-pointers/0011_container_with_most_water.cpp) |
| 42 | [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/) | 🔴 Hard | [C++](two-pointers/0042_trapping_rain_water.cpp) |
| 75 | [Sort Colors](https://leetcode.com/problems/sort-colors/) | 🟡 Medium | [C++](two-pointers/0075_sort_colors.cpp) |
| 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome/) | 🟢 Easy | [C++](two-pointers/0125_valid_palindrome.cpp) |
## 📝 Solution Template
Each solution file follows this structure:
- Problem description and link
- Approach explanation
- Time & Space complexity analysis
- Clean, commented code
- Test cases (when helpful)
## 🚀 How to Use
1. Clone the repository:
```bash
git clone https://github.com/aliataf/leetcode-solutions.git
```
2. Navigate to a topic folder and explore solutions
3. Compile and run a solution:
```bash
g++ -std=c++17 -o solution arrays/0001_two_sum.cpp && ./solution
```
## 🎯 Goals
- [ ] Solve 100 Easy problems
- [ ] Solve 150 Medium problems
- [ ] Solve 50 Hard problems
- [ ] Complete all Blind 75 problems
- [ ] Complete all NeetCode 150 problems
## 📚 Resources
- [LeetCode](https://leetcode.com/)
- [NeetCode](https://neetcode.io/)
- [Blind 75](https://leetcode.com/discuss/general-discussion/460599/blind-75-leetcode-questions)
---
⭐ Star this repo if you find it helpful!