This repository includes detailed solutions to problems I’ve solved on LeetCode, categorized by difficulty and approach.
| # | Problem Name | Topics | Level | Problem Link | Solution link |
|---|---|---|---|---|---|
| 1 | Two Sum | Easy | Link | ||
| 2 | Add Two Numbers | Medium | Link | ||
| 3 | Longest Substring Without Repeating Chars | Medium | Link | ||
| 4 | Median of Two Sorted Arrays | Hard | Link | ||
| 5 | Longest Palindromic Substring | Medium | Link | ||
| 6 | Zigzag Conversion | Medium | Link | ||
| 7 | Reverse Integer | Easy | Link | ||
| 8 | String to Integer (atoi) | Medium | Link | ||
| 9 | Palindrome Number | Easy | Link | ||
| 10 | Regular Expression Matching | Hard | Link | ||
| 11 | Container With Most Water | Medium | Link | ||
| 12 | Integer to Roman | Medium | Link | ||
| 13 | Roman to Integer | Easy | Link | ||
| 14 | Longest Common Prefix | Easy | Link | ||
| 15 | 3Sum | Medium | Link | ||
| 16 | 3Sum Closest | Medium | Link | ||
| 17 | Letter Combinations of a Phone Number | Medium | Link | ||
| 18 | 4Sum | Medium | Link | ||
| 19 | Remove Nth Node From End of List | Medium | Link | ||
| 20 | Valid Parentheses | Easy | Link | ||
| 21 | Merge Two Sorted Lists | Easy | Link | ||
| 22 | Generate Parentheses | Medium | Link | ||
| 23 | Merge k Sorted Lists | Hard | Link | ||
| 24 | Swap Nodes in Pairs | Medium | Link | ||
| 25 | Reverse Nodes in k-Group | Hard | Link | ||
| 26 | Remove Duplicates from Sorted Array | Easy | Link | ||
| 27 | Remove Element | Easy | Link | ||
| 28 | Find the Index of the First Occurrence in a String | Easy | Link | ||
| 29 | Divide Two Integers | Medium | Link | ||
| 30 | Substring with Concatenation of All Words | Hard | Link | ||
| 31 | Next Permutation | Medium | Link | ||
| 32 | Longest Valid Parentheses | Hard | Link | ||
| 33 | Search in Rotated Sorted Array | Medium | Link | ||
| 34 | Find First and Last Position of Element | Medium | Link | ||
| 35 | Search Insert Position | Easy | Link | ||
| 36 | Valid Sudoku | Medium | Link | ||
| 37 | Sudoku Solver | Hard | Link | ||
| 38 | Count and Say | Medium | Link | ||
| 39 | Combination Sum | Medium | Link | ||
| 40 | Combination Sum II | Medium | Link | ||
| 41 | First Missing Positive | Hard | Link | ||
| 42 | Trapping Rain Water | Hard | Link | ||
| 43 | Multiply Strings | Medium | Link | ||
| 44 | Wildcard Matching | Hard | Link | ||
| 45 | Jump Game II | Medium | Link | ||
| 46 | Permutations | Medium | Link | ||
| 47 | Permutations II | Medium | Link | ||
| 48 | Rotate Image | Medium | Link | ||
| 49 | Group Anagrams | Medium | Link | ||
| 50 | Pow(x, n) | Medium | Link | ||
| 51 | N-Queens | Hard | Link | ||
| 52 | N-Queens II | Hard | Link | ||
| 53 | Maximum Subarray | Easy | Link | ||
| 54 | Spiral Matrix | Medium | Link | ||
| 55 | Jump Game | Medium | Link | ||
| 56 | Merge Intervals | Medium | Link | ||
| 57 | Insert Interval | Medium | Link | ||
| 58 | Length of Last Word | Easy | Link | ||
| 59 | Spiral Matrix II | Medium | Link | ||
| 60 | Permutation Sequence | Hard | Link | ||
| 61 | Rotate List | Medium | Link | ||
| 62 | Unique Paths | Medium | Link | ||
| 63 | Unique Paths II | Medium | Link | ||
| 64 | Minimum Path Sum | Medium | Link | ||
| 65 | Valid Number | Hard | Link | ||
| 66 | Plus One | Easy | Link | ||
| 67 | Add Binary | Easy | Link | ||
| 68 | Text Justification | Hard | Link | ||
| 69 | Sqrt(x) | Easy | Link | ||
| 70 | Climbing Stairs | Easy | Link | ||
| 71 | Simplify Path | Medium | Link | ||
| 72 | Edit Distance | Hard | Link | ||
| 73 | Set Matrix Zeroes | Medium | Link | ||
| 74 | Search a 2D Matrix | Medium | Link | ||
| 75 | Sort Colors | Medium | Link | ||
| 76 | Minimum Window Substring | Hard | Link | ||
| 77 | Combinations | Medium | Link | ||
| 78 | Subsets | Medium | Link | ||
| 79 | Word Search | Medium | Link | ||
| 80 | Remove Duplicates from Sorted Array II | Medium | Link | ||
| 81 | Search in Rotated Sorted Array II | Medium | Link | ||
| 82 | Remove Duplicates from Sorted List II | Medium | Link | ||
| 83 | Remove Duplicates from Sorted List | Easy | Link | ||
| 84 | Largest Rectangle in Histogram | Hard | Link | ||
| 85 | Maximal Rectangle | Hard | Link | ||
| 86 | Partition List | Medium | Link | ||
| 87 | Scramble String | Hard | Link | ||
| 88 | Merge Sorted Array | Easy | Link | ||
| 89 | Gray Code | Medium | Link | ||
| 90 | Subsets II | Medium | Link | ||
| 91 | Decode Ways | Medium | Link | ||
| 92 | Reverse Linked List II | Medium | Link | ||
| 93 | Restore IP Addresses | Medium | Link | ||
| 94 | Binary Tree Inorder Traversal | Easy | Link | ||
| 95 | Unique Binary Search Trees II | Medium | Link | ||
| 96 | Unique Binary Search Trees | Medium | Link | ||
| 97 | Interleaving String | Medium | Link | ||
| 98 | Validate Binary Search Tree | Medium | Link | ||
| 99 | Recover Binary Search Tree | Hard | Link | ||
| 100 | Same Tree | Easy | Link | ||
| 101 | Symmetric Tree | Easy | Link | ||
| 102 | Binary Tree Level Order Traversal | Medium | Link | ||
| 103 | Binary Tree Zigzag Level Order Traversal | Medium | Link | ||
| 104 | Maximum Depth of Binary Tree | Easy | Link | ||
| 105 | Construct Binary Tree from Preorder and Inorder Traversal | Medium | Link | ||
| 106 | Construct Binary Tree from Inorder and Postorder Traversal | Medium | Link | ||
| 107 | Binary Tree Level Order Traversal II | Medium | Link | ||
| 108 | Convert Sorted Array to Binary Search Tree | Easy | Link | ||
| 109 | Convert Sorted List to Binary Search Tree | Medium | Link | ||
| 110 | Balanced Binary Tree | Easy | Link | ||
| 111 | Minimum Depth of Binary Tree | Easy | Link | ||
| 112 | Path Sum | Easy | Link | ||
| 113 | Path Sum II | Medium | Link | ||
| 114 | Flatten Binary Tree to Linked List | Medium | Link | ||
| 115 | Distinct Subsequences | Hard | Link | ||
| 116 | Populating Next Right Pointers in Each Node | Medium | Link | ||
| 117 | Populating Next Right Pointers in Each Node II | Medium | Link | ||
| 118 | Pascal's Triangle | Pattern, Recursion, DP, Basic Maths | Easy | Link | Solution |
| 119 | Pascal's Triangle II | Easy | Link | ||
| 120 | Triangle | Medium | Link | ||
| 121 | Best Time to Buy and Sell Stock | Easy | Link | ||
| 122 | Best Time to Buy and Sell Stock II | Medium | Link | ||
| 123 | Best Time to Buy and Sell Stock III | Hard | Link | ||
| 124 | Binary Tree Maximum Path Sum | Hard | Link | ||
| 125 | Valid Palindrome | Easy | Link | ||
| 126 | Word Ladder II | Hard | Link | ||
| 127 | Word Ladder | Hard | Link | ||
| 128 | Longest Consecutive Sequence | Medium | Link | ||
| 129 | Sum Root to Leaf Numbers | Medium | Link | ||
| 130 | Surrounded Regions | Medium | Link | ||
| 131 | Palindrome Partitioning | Medium | Link | ||
| 132 | Palindrome Partitioning II | Hard | Link | ||
| 133 | Clone Graph | Medium | Link | ||
| 134 | Gas Station | Medium | Link | ||
| 135 | Candy | Hard | Link | ||
| 136 | Single Number | Easy | Link | ||
| 137 | Single Number II | Medium | Link | ||
| 138 | Copy List with Random Pointer | Medium | Link | ||
| 139 | Word Break | Medium | Link | ||
| 140 | Word Break II | Hard | Link | ||
| 141 | Linked List Cycle | Easy | Link | ||
| 142 | Linked List Cycle II | Medium | Link | ||
| 143 | Reorder List | Medium | Link | ||
| 144 | Binary Tree Preorder Traversal | Easy | Link | ||
| 145 | Binary Tree Postorder Traversal | Easy | Link | ||
| 146 | LRU Cache | Medium | Link | ||
| 147 | Insertion Sort List | Medium | Link | ||
| 148 | Sort List | Medium | Link | ||
| 149 | Max Points on a Line | Hard | Link | ||
| 150 | Evaluate Reverse Polish Notation | Medium | Link | ||
| 151 | Reverse Words in a String | Medium | Link | ||
| 152 | Maximum Product Subarray | Medium | Link | ||
| 153 | Find Minimum in Rotated Sorted Array | Medium | Link | ||
| 154 | Find Minimum in Rotated Sorted Array II | Hard | Link | ||
| 155 | Min Stack | Easy | Link | ||
| 156 | Binary Tree Upside Down | Medium | Link | ||
| 157 | Read N Characters Given Read4 | Easy | Link | ||
| 158 | Read N Characters Given Read4 II - Call multiple times | Hard | Link | ||
| 159 | Longest Substring with At Most Two Distinct Characters | Hard | Link | ||
| 160 | Intersection of Two Linked Lists | Easy | Link | ||
| 161 | One Edit Distance | Medium | Link | ||
| 162 | Find Peak Element | Medium | Link | ||
| 163 | Missing Ranges | Medium | Link | ||
| 164 | Maximum Gap | Hard | Link | ||
| 165 | Compare Version Numbers | Medium | Link | ||
| 166 | Fraction to Recurring Decimal | Medium | Link | ||
| 167 | Two Sum II - Input Array Is Sorted | Medium | Link | ||
| 168 | Excel Sheet Column Title | Easy | Link | ||
| 169 | Majority Element | Easy | Link | ||
| 170 | Two Sum III - Data structure design | Easy | Link | ||
| 171 | Excel Sheet Column Number | Easy | Link | ||
| 172 | Factorial Trailing Zeroes | Medium | Link | ||
| 173 | Binary Search Tree Iterator | Medium | Link | ||
| 174 | Dungeon Game | Hard | Link | ||
| 175 | Combine Two Tables (SQL) | Easy | Link | ||
| 176 | Second Highest Salary (SQL) | Medium | Link | ||
| 177 | Nth Highest Salary (SQL) | Medium | Link | ||
| 178 | Rank Scores (SQL) | Medium | Link | ||
| 179 | Largest Number | Medium | Link | ||
| 180 | Consecutive Numbers (SQL) | Medium | Link | ||
| 181 | Employees Earning More Than Their Managers | Easy | Link | ||
| 182 | Duplicate Emails | Easy | Link | ||
| 183 | Customers Who Never Order | Easy | Link | ||
| 184 | Department Highest Salary | Medium | Link | ||
| 185 | Department Top Three Salaries | Hard | Link | ||
| 186 | Reverse Words in a String II | Medium | Link | ||
| 187 | Repeated DNA Sequences | Medium | Link | ||
| 188 | Best Time to Buy and Sell Stock IV | Medium | Link | ||
| 189 | Rotate Array | Medium | Link | ||
| 190 | Reverse Bits | Easy | Link | ||
| 191 | Number of 1 Bits | Easy | Link | ||
| 192 | Word Frequency | Easy | Link | ||
| 193 | Valid Phone Numbers | Easy | Link | ||
| 194 | Transpose File | Medium | Link | ||
| 195 | Tenth Line | Easy | Link | ||
| 196 | Delete Duplicate Emails | Medium | Link | ||
| 197 | Rising Temperature | Easy | Link | ||
| 198 | House Robber | Medium | Link | ||
| 199 | Binary Tree Right Side View | Medium | Link | ||
| 200 | Number of Islands | Medium | Link | ||
| 201 | Bitwise AND of Numbers Range | Medium | Link | ||
| 202 | Happy Number | Easy | Link | ||
| 203 | Remove Linked List Elements | Easy | Link | ||
| 204 | Count Primes | Medium | Link | ||
| 205 | Isomorphic Strings | Easy | Link | ||
| 206 | Reverse Linked List | Easy | Link | ||
| 207 | Course Schedule | Medium | Link | ||
| 208 | Implement Trie (Prefix Tree) | Medium | Link | ||
| 209 | Minimum Size Subarray Sum | Medium | Link | ||
| 210 | Course Schedule II | Medium | Link | ||
| 211 | Add and Search Word – Data structure design | Medium | Link | ||
| 212 | Word Search II | Hard | Link | ||
| 213 | House Robber II | Medium | Link | ||
| 214 | Shortest Palindrome | Hard | Link | ||
| 215 | Kth Largest Element in an Array | Medium | Link | ||
| 216 | Combination Sum III | Medium | Link | ||
| 217 | Contains Duplicate | Easy | Link | ||
| 218 | The Skyline Problem | Hard | Link | ||
| 219 | Contains Duplicate II | Easy | Link | ||
| 220 | Contains Duplicate III | Medium | Link | ||
| 221 | Maximal Square | Medium | Link | ||
| 222 | Count Complete Tree Nodes | Medium | Link | ||
| 223 | Rectangle Area | Medium | Link | ||
| 224 | Basic Calculator | Medium | Link | ||
| 225 | Implement Stack using Queues | Easy | Link | ||
| 226 | Invert Binary Tree | Easy | Link | ||
| 227 | Basic Calculator II | Medium | Link | ||
| 228 | Summary Ranges | Medium | Link | ||
| 229 | Majority Element II | Medium | Link | ||
| 230 | Kth Smallest Element in a BST | Medium | Link | ||
| 231 | Power of Two | Easy | Link | ||
| 232 | Implement Queue using Stacks | Easy | Link | ||
| 233 | Number of Digit One | Hard | Link | ||
| 234 | Palindrome Linked List | Easy | Link | ||
| 235 | Lowest Common Ancestor of a Binary Search Tree | Easy | Link | ||
| 236 | Lowest Common Ancestor of a Binary Tree | Easy | Link | ||
| 237 | Delete Node in a Linked List | Easy | Link | ||
| 238 | Product of Array Except Self | Medium | Link | ||
| 239 | Sliding Window Maximum | Hard | Link | ||
| 240 | Search a 2D Matrix II | Medium | Link | ||
| 241 | Different Ways to Add Parentheses | Medium | Link | ||
| 242 | Valid Anagram | Easy | Link | ||
| 243 | Shortest Word Distance | Easy | Link | ||
| 244 | Shortest Word Distance II | Medium | Link | ||
| 245 | Shortest Word Distance III | Hard | Link | ||
| 246 | Strobogrammatic Number | Easy | Link | ||
| 247 | Strobogrammatic Number II | Medium | Link | ||
| 248 | Strobogrammatic Number III | Hard | Link | ||
| 249 | Group Shifted Strings | Medium | Link | ||
| 250 | Count Univalue Subtrees | Easy | Link | ||
| 251 | Flatten 2D Vector | Medium | Link | ||
| 252 | Meeting Rooms | Easy | Link | ||
| 253 | Meeting Rooms II | Medium | Link | ||
| 254 | Factor Combinations | Medium | Link | ||
| 255 | Verify Preorder Sequence in Binary Search Tree | Medium | Link | ||
| 256 | Paint House | Easy | Link | ||
| 257 | Binary Tree Paths | Easy | Link | ||
| 258 | Add Digits | Easy | Link | ||
| 259 | 3Sum Smaller | Medium | Link | ||
| 260 | Single Number III | Medium | Link | ||
| 261 | Graph Valid Tree | Medium | Link | ||
| 262 | Trips and Users | Hard | Link | ||
| 263 | Ugly Number | Easy | Link | ||
| 264 | Ugly Number II | Medium | Link | ||
| 265 | Paint House II | Hard | Link | ||
| 266 | Palindrome Permutation | Easy | Link | ||
| 267 | Palindrome Permutation II | Medium | Link | ||
| 268 | Missing Number | Easy | Link | ||
| 269 | Alien Dictionary | Hard | Link | ||
| 270 | Closest Binary Search Tree Value | Easy | Link | ||
| 271 | Encode and Decode Strings | Medium | Link | ||
| 272 | Closest Binary Search Tree Value II | Medium | Link | ||
| 273 | Integer to English Words | Hard | Link | ||
| 274 | H-Index | Medium | Link | ||
| 275 | H-Index II | Medium | Link | ||
| 276 | Paint Fence | Medium | Link | ||
| 277 | Find the Celebrity | Medium | Link | ||
| 278 | First Bad Version | Easy | Link | ||
| 279 | Perfect Squares | Medium | Link | ||
| 280 | Wiggle Sort | Medium | Link | ||
| 281 | Zigzag Iterator | Medium | Link | ||
| 282 | Expression Add Operators | Hard | Link | ||
| 283 | Move Zeroes | Easy | Link | ||
| 284 | Peeking Iterator | Medium | Link | ||
| 285 | Inorder Successor in BST | Medium | Link | ||
| 286 | Walls and Gates | Medium | Link | ||
| 287 | Find the Duplicate Number | Medium | Link | ||
| 288 | Unique Word Abbreviation | Medium | Link | ||
| 289 | Game of Life | Medium | Link | ||
| 290 | Word Pattern | Easy | Link | ||
| 291 | Word Pattern II | Hard | Link | ||
| 292 | Nim Game | Easy | Link | ||
| 293 | Flip Game | Easy | Link | ||
| 294 | Flip Game II | Medium | Link | ||
| 295 | Find Median from Data Stream | Hard | Link | ||
| 296 | Best Meeting Point | Hard | Link | ||
| 297 | Serialize and Deserialize Binary Tree | Hard | Link | ||
| 298 | Binary Tree Longest Consecutive Sequence | Medium | Link | ||
| 299 | Bulls and Cows | Medium | Link | ||
| 300 | Longest Increasing Subsequence | Medium | Link |