Skip to content

Latest commit

 

History

History
208 lines (168 loc) · 9.7 KB

File metadata and controls

208 lines (168 loc) · 9.7 KB

LeetCode C++ Solutions Repository

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.

🎯 Purpose

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

🚀 Modern C++ Features

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

📚 Problems Solved

🎯 Array & Hashing

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:

Problems:

🎯 Sliding Window

Key Patterns:

  • Fixed Size Window: Analyze subarrays of fixed length k
  • Variable Size Window: Expand/shrink window based on constraints
  • Hash Map + Sliding Window: Track frequency/indices within window

Problems:

🎯 Stack

Key Patterns:

  • LIFO Operations: Valid Parentheses, Min Stack, Evaluate Reverse Polish Notation
  • Monotonic Stack: Daily Temperatures, Largest Rectangle in Histogram
  • Expression Evaluation: Evaluate Reverse Polish Notation
  • Nested Structure Processing: Valid Parentheses, Generate Parentheses
  • Auxiliary Stack: Min Stack (tracking minimum), Car Fleet (tracking time)

Problems:

🛠️ Development Setup

Simple Compilation

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

Compiler Requirements

  • GCC: Version 13+ with -std=c++23
  • Clang: Version 17+ with -std=c++23
  • MSVC: Version 19.35+ with /std:c++23

📝 Contributing

  1. Fork the repository
  2. Create a new branch for your solution
  3. Add your solution in the appropriate problem directory
  4. Follow the existing naming convention: Problem Number. Problem Name/
  5. Submit a pull request

Solution Guidelines

  • 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

🧠 Learning Approach

Comprehensive Documentation System

  • 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

Knowledge Building Strategy

  • 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

📊 Progress Tracking

Quick Stats

  • Total Problems: 30
  • Categories: Array & Hashing, Binary Search, Two Pointers, Sliding Window, Stack
  • Easy: 8 | Medium: 19 | Hard: 3

C++23 Features Used

  • STL Containers: std::unordered_map, std::unordered_set, std::priority_queue, std::vector, std::string, std::stack
  • 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, std::tuple
  • Two Pointers: Efficient array traversal, sliding window techniques, greedy algorithms
  • Stack Operations: LIFO data structure, monotonic stack patterns, expression evaluation, nested structure processing

📖 Learning Resources

Repository Documentation

External Resources

📄 License

This project is open source and available under the MIT License.

🤝 Acknowledgments

  • 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.