|
1 | | -# 🧮 LeetCode Solutions |
| 1 | +# Unit-Tested LeetCode Solutions |
2 | 2 |
|
3 | 3 | <div align="center"> |
4 | 4 |
|
5 | 5 | ### 🔬 Code Health & Testing |
6 | 6 |
|
7 | | -[](https://github.com/mathusanm6/LeetCode/actions/workflows/code-health-cpp.yml) |
8 | | -[](https://github.com/mathusanm6/LeetCode/actions/workflows/code-health-python.yml) |
| 7 | +[](https://github.com/mathusanm6/LeetCode/actions/workflows/code-health-cpp.yml) |
| 8 | +[](https://github.com/mathusanm6/LeetCode/actions/workflows/code-health-python.yml) |
9 | 9 |
|
10 | 10 | ### 🔍 Code Quality & Linting |
11 | 11 |
|
12 | | -[](https://github.com/mathusanm6/LeetCode/actions/workflows/linter-cpp.yml) |
13 | | -[](https://github.com/mathusanm6/LeetCode/actions/workflows/linter-python.yml) |
| 12 | +[](https://github.com/mathusanm6/LeetCode/actions/workflows/linter-cpp.yml) |
| 13 | +[](https://github.com/mathusanm6/LeetCode/actions/workflows/linter-python.yml) |
14 | 14 |
|
15 | 15 | ### 📊 Repository Stats |
16 | 16 |
|
17 | | -[](https://github.com/mathusanm6/LeetCode/commits/main) |
| 17 | +[](https://github.com/mathusanm6/LeetCode/commits/main) |
18 | 18 | [](https://github.com/mathusanm6/LeetCode/tree/main/problems) |
19 | | -[](https://github.com/mathusanm6/LeetCode/tree/main/problems) |
| 19 | +[](https://github.com/mathusanm6/LeetCode/tree/main/problems) |
20 | 20 |
|
21 | 21 | </div> |
22 | 22 |
|
23 | 23 | ## Description |
24 | 24 |
|
25 | | -This repository contains my solutions to LeetCode problems. I will be updating this repository with my solutions as I solve more problems. I have included a test suite for each solution. |
| 25 | +This repository contains comprehensive, unit-tested solutions to LeetCode problems implemented in both **C++20** and **Python 3**. Each solution includes: |
| 26 | + |
| 27 | +- 🧪 **Comprehensive test suites** with multiple test cases |
| 28 | +- 📝 **Detailed documentation** with complexity analysis |
| 29 | +- 🔧 **Automated code quality** checks and formatting |
| 30 | +- 🚀 **CI/CD pipeline** with automated testing and linting |
| 31 | + |
| 32 | +## 📁 Project Structure |
| 33 | + |
| 34 | +``` |
| 35 | +├── problems/ # Problem solutions organized by name |
| 36 | +│ ├── two_sum/ # Individual problem directories |
| 37 | +│ │ ├── config.yml # Problem metadata and configuration |
| 38 | +│ │ ├── two_sum.py # Python solution |
| 39 | +│ │ ├── two_sum.cc # C++ solution |
| 40 | +│ │ ├── two_sum.h # C++ header |
| 41 | +│ │ ├── two_sum_test.py # Python unit tests |
| 42 | +│ │ └── two_sum_test.cc # C++ unit tests |
| 43 | +│ └── ... |
| 44 | +├── config/ # Global configuration files |
| 45 | +│ ├── difficulties.yml # Difficulty level definitions |
| 46 | +│ └── tags.yml # Problem tag categories |
| 47 | +├── scripts/ # Automation and utility scripts |
| 48 | +│ ├── generate_readme.py # Auto-generate README content |
| 49 | +│ ├── update_badges.py # Update repository badges |
| 50 | +│ └── update_badges.sh # Badge update automation |
| 51 | +├── .github/workflows/ # CI/CD automation |
| 52 | +│ ├── code-health-*.yml # Comprehensive testing workflows |
| 53 | +│ ├── linter-*.yml # Code quality workflows |
| 54 | +│ ├── presubmit-*.yml # Pre-merge validation |
| 55 | +│ └── update-badges.yml # Automated badge updates |
| 56 | +├── Makefile # Build and test automation |
| 57 | +├── requirements.txt # Python dependencies |
| 58 | +├── .clang-format # C++ code formatting rules |
| 59 | +└── .clang-tidy # C++ linting configuration |
| 60 | +``` |
| 61 | + |
| 62 | +## 🛠️ Technologies & Tools |
| 63 | + |
| 64 | +### Languages & Standards |
| 65 | + |
| 66 | +- **C++**: C++20 with modern features and best practices |
| 67 | +- **Python**: Python 3.x with type hints and modern syntax |
| 68 | + |
| 69 | +### Testing Frameworks |
| 70 | + |
| 71 | +- **C++**: Google Test (gtest) for comprehensive unit testing |
| 72 | +- **Python**: pytest with coverage reporting |
| 73 | + |
| 74 | +### Code Quality Tools |
| 75 | + |
| 76 | +- **C++ Formatting**: clang-format for consistent code style |
| 77 | +- **C++ Linting**: clang-tidy for static analysis and best practices |
| 78 | +- **Python Formatting**: ruff for fast, comprehensive code formatting |
| 79 | +- **Python Linting**: ruff for linting, import sorting, and code quality |
| 80 | + |
| 81 | +### Build & Automation |
| 82 | + |
| 83 | +- **Make**: Cross-platform build system with intelligent target detection |
| 84 | +- **GitHub Actions**: Automated CI/CD with parallel testing and validation |
26 | 85 |
|
27 | 86 | ## Running Tests |
28 | 87 |
|
29 | | -### Python Tests |
| 88 | +The project includes comprehensive test suites for all solutions with cross-platform support. |
30 | 89 |
|
31 | | -To run the Python test suite, use the following commands in **the repository directory**: |
| 90 | +### 🐍 Python Tests |
32 | 91 |
|
33 | 92 | ```bash |
34 | | -# Run all Python tests |
| 93 | +# Run all Python tests with coverage |
35 | 94 | make test-py:all |
36 | 95 |
|
37 | 96 | # Run tests for a specific problem (e.g., two-sum) |
38 | 97 | make test-py:two-sum |
39 | 98 | ``` |
40 | 99 |
|
41 | | -### C++ Tests |
42 | | - |
43 | | -To run the C++ test suite, use the following commands in the repository directory: |
| 100 | +### ⚡ C++ Tests |
44 | 101 |
|
45 | 102 | ```bash |
46 | | -# Run all C++ tests |
| 103 | +# Run all C++ tests (auto-detects macOS/Linux) |
47 | 104 | make test-cpp:all |
48 | 105 |
|
49 | 106 | # Run tests for a specific problem (e.g., two-sum) |
50 | 107 | make test-cpp:two-sum |
51 | 108 |
|
52 | | -# Run both C++ and Python tests for all problems |
| 109 | +# Run all tests (both languages) |
53 | 110 | make test:all |
54 | 111 | ``` |
55 | 112 |
|
| 113 | +**Requirements:** |
| 114 | + |
| 115 | +- **macOS**: `brew install googletest` |
| 116 | +- **Linux**: `sudo apt-get install libgtest-dev` or build from source |
| 117 | + |
56 | 118 | ## Code Quality |
57 | 119 |
|
58 | | -This project includes comprehensive code quality tools and automated linting: |
| 120 | +This project maintains high code quality standards through automated tooling and CI/CD integration. |
59 | 121 |
|
60 | | -### Linting and Formatting |
| 122 | +### 🎨 Formatting & Linting |
61 | 123 |
|
62 | 124 | ```bash |
63 | | -# Format all code (C++ and Python) |
| 125 | +# Format all code (C++ with clang-format, Python with ruff) |
64 | 126 | make format |
65 | 127 |
|
66 | | -# Lint all code (C++ and Python) |
| 128 | +# Lint all code with comprehensive checks |
67 | 129 | make lint |
68 | 130 |
|
69 | | -# Format/lint specific languages |
| 131 | +# Language-specific operations |
70 | 132 | make format-cpp # Format C++ files with clang-format |
71 | 133 | make format-python # Format Python files with ruff |
72 | 134 | make lint-cpp # Lint C++ files with clang-tidy |
73 | 135 | make lint-python # Lint Python files with ruff |
74 | 136 | ``` |
75 | 137 |
|
76 | | -### Continuous Integration |
| 138 | +### 🔄 Continuous Integration |
| 139 | + |
| 140 | +The project includes a comprehensive CI/CD pipeline: |
77 | 141 |
|
78 | | -- **Linters**: Automated code formatting and linting checks on every push/PR |
79 | | -- **Presubmit**: Comprehensive testing of changed files before merge |
80 | | -- **Postsubmit**: Full test suite execution after merge to main branch |
81 | | -- All workflows leverage the project's Makefile for consistency |
| 142 | +- **🔍 Presubmit Checks**: Validate code changes before merge |
| 143 | + - Format validation (clang-format, ruff) |
| 144 | + - Linting checks (clang-tidy, ruff) |
| 145 | + - Unit test execution for changed files |
| 146 | +- **🧪 Code Health**: Full validation after merge to main |
82 | 147 |
|
83 | | -## Algorithms |
| 148 | + - Complete test suite execution |
| 149 | + - Cross-platform compatibility testing |
| 150 | + - Coverage reporting |
| 151 | + |
| 152 | +- **📊 Automated Maintenance**: |
| 153 | + - Badge updates reflecting current status |
| 154 | + - PR size labeling for review optimization |
| 155 | + - Workflow status monitoring |
| 156 | + |
| 157 | +All workflows leverage the project's Makefile for consistency across local development and CI environments. |
| 158 | + |
| 159 | +## 🧮 Algorithms & Data Structures |
| 160 | + |
| 161 | +This repository covers a comprehensive range of algorithmic patterns and data structures commonly found in technical interviews: |
84 | 162 |
|
85 | 163 | - [Arrays & Hashing](#arrays--hashing) |
86 | 164 | - [Two Pointers](#two-pointers) |
@@ -111,7 +189,3 @@ make lint-python # Lint Python files with ruff |
111 | 189 | | # | Title | Solution | Time | Space | Difficulty | Tag | Note | |
112 | 190 | |---|-------|----------|------|-------|------------|-----|------| |
113 | 191 | | 125 | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome/) | [Python](./problems/valid_palindrome/valid_palindrome.py), [C++](./problems/valid_palindrome/valid_palindrome.cc) | _O(n)_ | _O(1)_ | Easy | | | |
114 | | - |
115 | | -## License |
116 | | - |
117 | | -This project is licensed under the MIT License - see the LICENSE file for details. |
|
0 commit comments