This repository contains my C++ solutions for various LeetCode problems, organized by category. Each entry links to the original problem, shows its difficulty, and links to the solution file. This README serves as a quick reference guide to navigate through the solutions.
The solutions are categorized based on the type of problem or algorithm used. Each solution file has complete information about the problem, including the problem statement, constraints, and the implemented solution.
| Problem | Difficulty | Solution |
|---|---|---|
| 41. First Missing Positive | Hard | Solution |
| 53. Maximum Subarray | Medium | Solution |
| 56. Merge Intervals | Medium | Solution |
| 68. Text Justification | Hard | Solution |
| 75. Sort Colors | Medium | Solution |
| 128. Longest Consecutive Sequence | Medium | Solution |
| 138. Copy List with Random Pointer | Medium | Solution |
| 189. Rotate Array | Medium | Solution |
| 229. Majority Element II | Medium | Solution |
| 268. Missing Number | Easy | Solution |
| 274. H-Index | Medium | Solution |
| 287. Find the Duplicate Number | Medium | Solution |
| 324. Wiggle Sort II | Medium | Solution |
| 414. Third Maximum Number | Easy | Solution |
| 442. Find All Duplicates in an Array | Medium | Solution |
| 448. Find All Numbers Disappeared in an Array | Easy | Solution |
| 485. Max Consecutive Ones | Easy | Solution |
| 1679. Max Number of K-Sum Pairs | Medium | Solution |
| 1752. Check if Array Is Sorted and Rotated | Easy | Solution |
| 2615. Sum of Distances | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 6. Zigzag Conversion | Medium | Solution |
| 8. String to Integer (atoi) | Medium | Solution |
| 12. Integer to Roman | Medium | Solution |
| 14. Longest Common Prefix | Easy | Solution |
| 38. Count and Say | Medium | Solution |
| 43. Multiply Strings | Medium | Solution |
| 49. Group Anagrams | Medium | Solution |
| 151. Reverse Words in a String | Medium | Solution |
| 205. Isomorphic Strings | Easy | Solution |
| 290. Word Pattern | Easy | Solution |
| 316. Remove Duplicate Letters | Medium | Solution |
| 392. Is Subsequence | Easy | Solution |
| 438. Find All Anagrams in a String | Medium | Solution |
| 443. String Compression | Medium | Solution |
| 451. Sort Characters By Frequency | Medium | Solution |
| 567. Permutation in String | Medium | Solution |
| 890. Find and Replace Pattern | Medium | Solution |
| 1209. Remove All Adjacent Duplicates in String II | Medium | Solution |
| 2785. Sort Vowels in a String | Medium | Solution |
| 3043. Find the Length of the Longest Common Prefix | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 48. Rotate Image | Medium | Solution |
| 54. Spiral Matrix | Medium | Solution |
| 59. Spiral Matrix II | Medium | Solution |
| 73. Set Matrix Zeroes | Medium | Solution |
| 74. Search a 2D Matrix | Medium | Solution |
| 867. Transpose Matrix | Easy | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 454. 4Sum II | Medium | Solution |
| 532. K-diff Pairs in an Array | Medium | Solution |
| 2352. Equal Row and Column Pairs | Medium | Solution |
| 3583. Count Special Triplets | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 11. Container With Most Water | Medium | Solution |
| 15. 3Sum | Medium | Solution |
| 42. Trapping Rain Water | Hard | Solution |
| 80. Remove Duplicates from Sorted Array II | Medium | Solution |
| 167. Two Sum II - Input Array Is Sorted | Medium | Solution |
| 922. Sort Array By Parity II | Easy | Solution |
| 2149. Rearrange Array Elements by Sign | Medium | Solution |
| 2161. Partition Array According to Given Pivot | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 238. Product of Array Except Self | Medium | Solution |
| 304. Range Sum Query 2D - Immutable | Medium | Solution |
| 523. Continuous Subarray Sum | Medium | Solution |
| 525. Contiguous Array | Medium | Solution |
| 560. Subarray Sum Equals K | Medium | Solution |
| 724. Find Pivot Index | Easy | Solution |
| 1124. Longest Well-Performing Interval | Medium | Solution |
| 2488. Count Subarrays With Median K | Hard | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 20. Valid Parentheses | Easy | Solution |
| 32. Longest Valid Parentheses | Hard | Solution |
| 84. Largest Rectangle in Histogram | Hard | Solution |
| 85. Maximal Rectangle | Hard | Solution |
| 150. Evaluate Reverse Polish Notation | Medium | Solution |
| 155. Min Stack | Medium | Solution |
| 224. Basic Calculator | Hard | Solution |
| 227. Basic Calculator II | Medium | Solution |
| 239. Sliding Window Maximum | Hard | Solution |
| 394. Decode String | Medium | Solution |
| 402. Remove K Digits | Medium | Solution |
| 496. Next Greater Element I | Easy | Solution |
| 503. Next Greater Element II | Medium | Solution |
| 636. Exclusive Time of Functions | Medium | Solution |
| 739. Daily Temperatures | Medium | Solution |
| 853. Car Fleet | Medium | Solution |
| 901. Online Stock Span | Medium | Solution |
| 907. Sum of Subarray Minimums | Medium | Solution |
| 1441. Build an Array With Stack Operations | Medium | Solution |
| 2104. Sum of Subarray Ranges | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| Stack using Arrays | Easy | Solution |
| Queue using Arrays | Easy | Solution |
| Stack using Queue | Easy | Solution |
| Queue using Stack | Easy | Solution |
| Previous Smaller Element | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 2. Add Two Numbers | Medium | Solution |
| 19. Remove Nth Node From End of List | Medium | Solution |
| 23. Merge k Sorted Lists | Hard | Solution |
| 25. Reverse Nodes in k-Group | Hard | Solution |
| 61. Rotate List | Medium | Solution |
| 86. Partition List | Medium | Solution |
| 92. Reverse Linked List II | Medium | Solution |
| 141. Linked List Cycle | Easy | Solution |
| 142. Linked List Cycle II | Medium | Solution |
| 143. Reorder List | Medium | Solution |
| 148. Sort List | Medium | Solution |
| 160. Intersection of Two Linked Lists | Easy | Solution |
| 206. Reverse Linked List | Easy | Solution |
| 237. Delete Node in a Linked List | Medium | Solution |
| 328. Odd Even Linked List | Medium | Solution |
| 445. Add Two Numbers II | Medium | Solution |
| 876. Middle of the Linked List | Easy | Solution |
| 2095. Delete the Middle Node of a Linked List | Medium | Solution |
| 2487. Remove Nodes From Linked List | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 23. Merge k Sorted Lists | Hard | Solution |
| 215. Kth Largest Element in an Array | Medium | Solution |
| 295. Find Median from Data Stream | Hard | Solution |
| 347. Top K Frequent Elements | Medium | Solution |
| 355. Design Twitter | Medium | Solution |
| 378. Kth Smallest Element in a Sorted Matrix | Medium | Solution |
| 407. Trapping Rain Water II | Hard | Solution |
| 502. IPO | Hard | Solution |
| 621. Task Scheduler | Medium | Solution |
| 692. Top K Frequent Words | Medium | Solution |
| 703. Kth Largest Element in a Stream | Easy | Solution |
| 846. Hand of Straights | Medium | Solution |
| 973. K Closest Points to Origin | Medium | Solution |
| 1046. Last Stone Weight | Easy | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 45. Jump Game II | Medium | Solution |
| 55. Jump Game | Medium | Solution |
| 57. Insert Interval | Medium | Solution |
| 134. Gas Station | Medium | Solution |
| 135. Candy | Hard | Solution |
| 179. Largest Number | Medium | Solution |
| 334. Increasing Triplet Subsequence | Medium | Solution |
| 435. Non-overlapping Intervals | Medium | Solution |
| 455. Assign Cookies | Easy | Solution |
| 678. Valid Parenthesis String | Medium | Solution |
| 860. Lemonade Change | Easy | Solution |
| 1899. Merge Triplets to Form Target Triplet | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 211. Design Add and Search Words Data Structure | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 17. Letter Combinations of a Phone Number | Medium | Solution |
| 37. Sudoku Solver | Hard | Solution |
| 39. Combination Sum | Medium | Solution |
| 40. Combination Sum II | Medium | Solution |
| 46. Permutations | Medium | Solution |
| 50. Pow(x, n) | Medium | Solution |
| 90. Subsets II | Medium | Solution |
| 131. Palindrome Partitioning | Medium | Solution |
| 216. Combination Sum III | Medium | Solution |
| 1922. Count Good Numbers | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 3100. Water Bottles II | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 126. Word Ladder II | Hard | Solution |
| 127. Word Ladder | Hard | Solution |
| 130. Surrounded Regions | Medium | Solution |
| 133. Clone Graph | Medium | Solution |
| 200. Number of Islands | Medium | Solution |
| 365. Water and Jug Problem | Medium | Solution |
| 399. Evaluate Division | Medium | Solution |
| 417. Pacific Atlantic Water Flow | Medium | Solution |
| 433. Minimum Genetic Mutation | Medium | Solution |
| 542. 01 Matrix | Medium | Solution |
| 695. Max Area of Island | Medium | Solution |
| 752. Open the Lock | Medium | Solution |
| 773. Flood Fill | Easy | Solution |
| 785. Is Graph Bipartite | Medium | Solution |
| 841. Keys and Rooms | Medium | Solution |
| 909. Snakes and Ladders | Medium | Solution |
| 994. Rotting Oranges | Medium | Solution |
| 1020. Number of Enclaves | Medium | Solution |
| 1926. Nearest Exit from Entrance in Maze | Medium | Solution |
| 2477. Minimum Fuel Cost to Report to the Capital | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 207. Course Schedule | Medium | Solution |
| 210. Course Schedule II | Medium | Solution |
| 329. Longest Increasing Path in a Matrix | Hard | Solution |
| 802. Find Eventual Safe States | Medium | Solution |
| 851. Loud and Rich | Medium | Solution |
| 1462. Course Schedule IV | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 743. Network Delay Time | Medium | Solution |
| 787. Cheapest Flights Within K Stops | Medium | Solution |
| 1091. Shortest Path in Binary Matrix | Medium | Solution |
| 1334. City with the Smallest Number of Neighbors | Medium | Solution |
| 1631. Path With Minimum Effort | Medium | Solution |
| 1976. Number of Ways to Arrive at Destination | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 547. Number of Provinces | Medium | Solution |
| 684. Redundant Connection | Medium | Solution |
| 947. Most Stones Removed with Same Row or Column | Medium | Solution |
| 1319. Operations to Make Network Connected | Medium | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| 70. Climbing Stairs | Easy | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| Morris Inorder Traversal | Easy | Solution |
| Morris Preorder Traversal | Easy | Solution |
| Boundary Traversal of Binary Tree | Medium | Solution |
| Top View of Binary Tree | Medium | Solution |
| Bottom View of Binary Tree | Medium | Solution |
| Find Ceil in a BST | Easy | Solution |
| Problem | Difficulty | Solution |
|---|---|---|
| Topological Sorting - DFS | Medium | Solution |
| Topological Sorting - BFS | Medium | Solution |
| Shortest Path in DAG | Hard | Solution |
| Dijkstra's Algorithm | Medium | Solution |
| Bellmann Ford Algorithm | Medium | Solution |
| Floyd Warshall (APSP) | Medium | Solution |
| Prim's Algorithm (MST) | Medium | Solution |
| Disjoint Set (Union by Rank) | Medium | Solution |