A collection of LeetCode algorithm problem solutions implemented in modern C++. This repository serves as a learning platform to help me become a master of C++ and DSA through systematic problem-solving.
This repository is designed for:
- Learning and mastering DSA concepts through practical problem-solving
- Improving C++ programming skills using modern features when beneficial
- Building comprehensive knowledge of algorithms and data structures
- Systematic learning to become a C++ and DSA master
This repository uses modern C++ features to write clean, efficient, and maintainable solutions:
- Modern algorithms - Range-based algorithms and efficient data processing
- Smart containers - Appropriate data structures for each problem
- Error handling - Robust and safe code practices
- Advanced concepts - Templates, concepts, and compile-time features
- Performance optimization - Move semantics, perfect forwarding, and efficient code
Key Patterns:
- Hash Map/Set: Two Sum, Contains Duplicate, Valid Anagram, Group Anagrams
- Array Manipulation: Product of Array Except Self, Longest Consecutive Sequence
- String Processing: Valid Anagram, Group Anagrams, Encode and Decode Strings
- Matrix/2D Arrays: Valid Sudoku
- Frequency Counting: Top K Frequent Elements, Valid Anagram, Group Anagrams
Problems:
- 1. Two Sum - Easy
- 36. Valid Sudoku - Medium
- 49. Group Anagrams - Medium
- 128. Longest Consecutive Sequence - Medium
- 217. Contains Duplicate - Easy
- 238. Product of Array Except Self - Medium
- 242. Valid Anagram - Easy
- 271. Encode and Decode Strings - Medium
- 347. Top K Frequent Elements - Medium
Key Patterns:
- Opposite Direction: Valid Palindrome, Container With Most Water
- Same Direction: Two Sum II - Input Array Is Sorted, 3Sum
- Prefix/Suffix Arrays: Trapping Rain Water
- Greedy + Two Pointers: Container With Most Water
- Sorting + Two Pointers: 3Sum
Problems:
- 11. Container With Most Water - Medium
- 15. 3Sum - Medium
- 42. Trapping Rain Water - Hard
- 125. Valid Palindrome - Easy
- 167. Two Sum II - Input Array Is Sorted - Easy
For basic testing, you can compile individual solutions:
# Navigate to problem directory
cd "src/1. Two Sum"
# Compile with C++23
g++ -std=c++23 -O2 main.cpp -o solution
# or
clang++ -std=c++23 -O2 main.cpp -o solution
# Run
./solution- GCC: Version 13+ with
-std=c++23 - Clang: Version 17+ with
-std=c++23 - MSVC: Version 19.35+ with
/std:c++23
- Fork the repository
- Create a new branch for your solution
- Add your solution in the appropriate problem directory
- Follow the existing naming convention:
Problem Number. Problem Name/ - Submit a pull request
- Use C++23 standard - Leverage modern features when beneficial
- Write clear, readable code with proper comments
- Include problem description in comments
- Follow C++23 best practices - RAII, smart pointers, constexpr
- Test solutions with multiple test cases
- Include time and space complexity analysis
- Document C++23 features used in your solution
- Problem-Specific Learning: Each problem includes detailed README with multiple approaches
- C++ Mastery: Extensive C++ documentation covering fundamentals to advanced topics
- DSA Foundation: Complete data structures and algorithms reference
- Pattern Recognition: Common algorithmic patterns and when to use them
- Progressive Learning: Structured roadmap from basics to advanced concepts
- Theory + Practice: Combine conceptual understanding with hands-on coding
- Multiple Solutions: Learn different approaches to the same problem
- Modern C++: Use latest C++23 features for efficient and clean code
- Systematic Progress: Track learning through comprehensive documentation
- Mastery Focus: Deep understanding over quick solutions
- Total Problems: 14
- Categories: Array & Hashing, Two Pointers
- Easy: 5 | Medium: 8 | Hard: 1
- STL Containers: std::unordered_map, std::unordered_set, std::priority_queue, std::vector, std::string
- STL Algorithms: std::sort, std::transform, std::accumulate, std::ranges, std::is_sorted, std::max_element
- Modern C++: std::ranges, std::views, std::format, auto keyword, structured bindings, constexpr
- Two Pointers: Efficient array traversal, sliding window techniques, greedy algorithms
- Learning Roadmap - Comprehensive learning path for C++ and DSA mastery
- C++ Documentation - Complete C++ programming concepts and modern features
- DSA Documentation - Data structures and algorithms fundamentals to advanced topics
- Algorithm Patterns - Common algorithmic patterns and techniques
- Problem Categories - Problems organized by topic and difficulty
- LeetCode Official Website
- Neetcode 150 Roadmap
- C++23 Reference
- C++23 Standard
- std::ranges Documentation
- std::views Documentation
- Algorithm Visualization
- C++ Core Guidelines
- Modern C++ Features
This project is open source and available under the MIT License.
- ISO C++ Committee for C++23 standard
- LeetCode for providing excellent algorithmic problems
- The C++ community for continuous improvements to the language
- All contributors who help improve this repository
Happy Learning! πβ¨
This repository is designed for comprehensive learning and mastery building, focusing on DSA concepts and modern C++ programming.