This repository contains solutions to various LeetCode problems, primarily implemented in C++ with some Java solutions. The problems cover a wide range of data structures and algorithms topics, perfect for interview preparation and competitive programming practice.
- Total Problems: 68
- Easy: 33 problems
- Medium: 32 problems
- Hard: 3 problems
# | Problem | Solution | Difficulty |
---|---|---|---|
315 | Count of Smaller Numbers After Self | C++ | Hard |
407 | Trapping Rain Water II | C++ | Hard |
493 | Reverse Pairs | C++ | Hard |
- Arrays: Two Sum, Move Zeroes, Rotate Array, Majority Element, Remove Duplicates
- Dynamic Programming: Climbing Stairs, Fibonacci Number, Maximum Subarray, Maximum Product Subarray
- Matrix Operations: Rotate Image, Spiral Matrix, Set Matrix Zeroes, Search 2D Matrix
- Searching: Binary Search, Search in Rotated Sorted Array, Find First and Last Position
- Sorting: Sort Colors, Sort an Array, Merge Intervals
- Stack: Valid Parentheses, Min Stack, Next Greater Element I/II/III
- String Manipulation: Zigzag Conversion, Valid Anagram, Is Subsequence
- Math: Reverse Integer, Sqrt(x), Pascal's Triangle, Power of Two
- Greedy: Best Time to Buy and Sell Stock, Container With Most Water, Gas Station
- Hashing: Two Sum, Single Number, Majority Element
- Two Pointers: Move Zeroes, Sort Colors, Merge Sorted Array
- Divide & Conquer: Reverse Pairs, Count of Smaller Numbers After Self
- Bit Manipulation: Single Number, Power of Two, Sign of Product
- Graph/DFS/BFS: Pacific Atlantic Water Flow, Trapping Rain Water II
Each problem is organized in its own directory with the following structure:
problem-number-problem-name/
├── README.md # Problem description from LeetCode
└── problem-name.cpp # C++ solution
- Browse Problems: Navigate through the categorized problem list above
- Study Solutions: Each problem folder contains:
README.md
: Original problem description from LeetCode- Solution file (
.cpp
or.java
): Commented code with explanations
- Practice: Try solving the problems yourself before looking at the solutions
- Learn: Study the approaches, time/space complexity, and patterns used
Contributions are welcome! If you'd like to add more solutions or improve existing ones:
- Fork the repository
- Create a new branch (
git checkout -b feature/new-solution
) - Add your solution following the existing structure
- Commit your changes (
git commit -m 'Add solution for Problem XYZ'
) - Push to the branch (
git push origin feature/new-solution
) - Open a Pull Request
- Use clear and descriptive variable names
- Add comments explaining complex logic
- Include time and space complexity analysis where applicable
- Follow consistent code formatting
Feel free to explore the solutions and learn from them. If you have any suggestions or improvements, contributions are welcome!
If you find this repository helpful, please consider giving it a star! It helps others discover these solutions.
Note: This repository is maintained for educational purposes and interview preparation. All solutions are original implementations based on LeetCode problem descriptions.