A collection of LeetCode problem solutions implemented in modern C++ (C++17+). Each problem lives in its own folder and may include multiple approach variants and a short problem README.
Quick start
- Build a single solution using
g++:
g++ -std=c++17 -O2 path/to/problem/solution.cpp -o solution && ./solutionOn Windows PowerShell (if g++ is in PATH):
g++ -std=c++17 -O2 .\0001-two-sum\solution.cpp -o solution.exe; .\solution.exeRepository layout
- Top-level directories are named like
0001-two-sum/,0002-add-two-numbers/, etc. - Inside a problem folder you typically find:
solution.cpp— main solution- other variants (e.g.
brute_force.cpp,two_pointer.cpp,hashing.cpp) README.md— short explanation, approach and complexity
How to add a new problem
- Create a folder with a zero-padded number and short name (e.g.
0123-my-problem/). - Add
solution.cpp(and other variants if needed). - Add
README.mddescribing the approach, time and space complexity, and edge cases.
Notes and conventions
- Use readable, idiomatic C++ and prefer clarity over clever micro-optimizations.
- Solutions that require input should read from
stdinso they can be tested with redirection.
Contributing
- Fork, add or update a problem folder, then open a pull request with a short description.
License
- No license is included. Add a
LICENSEfile if you want to set reuse terms.
That's it - simple, searchable C++ solutions intended for study and practice.