π₯ Video explanations available: Each solution in this repository is accompanied by a detailed walkthrough on my YouTube channel β @TrulyLearnedMe. The videos focus on reasoning, trade-offs, and clean Modern C++ implementation.
A fully reproducible Modern C++ project template for solving and testing LeetCode problems.
All problem directories are stored under the top-level code/ folder, each following an identical structure designed for clarity, testing, and IDE integration.
code/
 βββ 0001_LC_1_Easy_Two_Sum/
 β    βββ .vscode/
 β    β    βββ c_cpp_properties.json
 β    β    βββ launch.json
 β    β    βββ settings.json
 β    β    βββ tasks.json
 β    βββ include/
 β    β    βββ solution.h                 # Primary, tested solution
 β    β    βββ solution_brute_force.h     # Alternative approach
 β    β    βββ solution_optimal.h         # Alternative approach
 β    βββ src/
 β    β    βββ main.cpp                   # Optional demo entry point
 β    βββ tests/
 β    β    βββ tests.cpp                  # GoogleTest unit tests
 β    βββ CMakeLists.txt
 βββ 0002_LC_20_Easy_Valid_Parentheses/
 β    βββ ...
 βββ ...
- Every folder inside code/is independent and self-contained.
- Alternative solutions follow the naming pattern solution_<description>.h.
- main.cppis only for manual debugging; automated tests are run via GoogleTest.
(Tested with C++23 β fully compatible with C++20)
| Platform | Compiler | C++ Standard | Status | 
|---|---|---|---|
| macOS 14 + | Clang 17 + | C++23 (β C++20) | β | 
| Windows 11 | MSVC 2022 + | C++23 (β C++20) | β | 
| Ubuntu 24.04 + | GCC 15 + | C++23 (β C++20) | β | 
All builds use strict warnings (-Wall -Wextra -Wpedantic or /W4) and contain no platform-specific code.
The same project compiles cleanly and behaves identically across macOS, Windows, and Linux.
Each problem folder contains its own test suite (tests/tests.cpp).
GoogleTest is automatically fetched by CMake.
Build and run tests:
cmake -S . -B build
cmake --build build
cd build
ctest --output-on-failure- 
Install the following extensions: - C/C++ (Microsoft)
- CMake Tools
- CTest Adapter (optional)
 
- 
Open the problem folder (e.g., code/0001_LC_1_Easy_Two_Sum) as a VS Code workspace.
- 
Configure with CMake ( Ctrl + Shift + P β CMake: Configure).
- 
Run or debug either: - the dummy apptarget (for quick manual runs), or
- the problem_teststarget (for unit testing).
 
- the dummy 
All .vscode/*.json files are pre-configured for convenient IntelliSense, build, and debugging.
- 
Each problem defines a small solution_lib(INTERFACE library) so headers can be shared between the runner and tests.- This library is header-only β it doesnβt compile code itself.
- It simply exports include paths, C++ standard settings, and compiler flags to any target that links against it.
- Both the executable (app) and the test binary (problem_tests) link to this same library, ensuring consistent configuration and zero duplication.
 
- 
CMake enables CTestand registers all GoogleTests automatically.
- 
Every solution header documents algorithmic complexity and design remarks. 
To add a new problem:
- Duplicate any existing numbered folder inside code/.
- Update the name and CMakeLists.txtproject()line.
- Replace contents of include/solution.hand adjusttests/tests.cpp.
- Re-run CMake and tests.
Optionally, a root-level CMakeLists.txt can be created to include all subprojects in the code/ folder automatically.
MIT β free to fork, learn from, and adapt.