# LeetCode
**Repository Path**: bee19940901/leet-code
## Basic Information
- **Project Name**: LeetCode
- **Description**: Bee的力扣算法刷题笔记(C++)
- **Primary Language**: C++
- **License**: MIT
- **Default Branch**: master
- **Homepage**: https://leetcode.cn/u/bee0901
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-12-15
- **Last Updated**: 2026-05-09
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 🚀 LeetCode C++ Solutions
**精选 600+ 道 LeetCode 题解,基于现代 C++23 标准的高质量算法库**
[✨ 核心特点](#-项目特点) • [📊 刷题进度](#-数据统计) • [🏗️ 目录结构](#-目录结构) • [🛠️ 快速开始](#-快速开始)
---
## 💡 项目特点
- **🌟 现代编程范式**:深度应用 **C++23** 标准特性(如 `std::views`, `ranges`, `expected` 等),提供更简洁、更安全的解法。
- **🧪 工业级测试**:基于 **Google Test** 框架构建完整的单元测试套件,确保每一行逻辑的正确性。
- **📂 结构化工程**:遵循标准 CMake 项目布局,代码组织清晰,支持一键编译与性能分析。
- **✍️ 规范化代码**:严格遵守编码规范,包含详尽的逻辑注释与复杂度说明。
---
## 📊 数据统计
| 类别 | 详情 |
| :--- | :--- |
| **题解总数** | `600+` 道经典算法题目 |
| **代码总量** | `52,000+` 行核心逻辑 |
| **单元测试** | `40+` 套验证用例,持续完善中 |
| **覆盖标准** | 涵盖数组、链表、树、动态规划、图论等全领域 |
### 📂 覆盖范围
| 目录范围 | 题量 | 目录范围 | 题量 |
| :--- | :--- | :--- | :--- |
| `solution 1-100` | 21 | `solution 101-200` | 27 |
| `solution 201-300` | 24 | `solution 301-400` | 15 |
| `solution 401-500` | 18 | `solution 501-600` | 18 |
| `solution 601-700` | 15 | `solution 701-800` | 9 |
| `solution 801-900` | 10 | `solution 901-1000` | 11 |
| `solution 1001-1100`| 12 | `solution 1101-1200`| 6 |
| `solution 1201-1300`| 7 | `solution 1301-1400`| 19 |
| `solution 1401-1500`| 17 | `solution 1501-1600`| 17 |
| `solution 1601-1700`| 17 | `solution 1701-1800`| 19 |
| `solution 1801-1900`| 16 | `solution 1901-2000`| 17 |
| `solution 2001-2100`| 17 | `solution 2101-2200`| 21 |
| `solution 2201-2300`| 16 | `solution 2301-2400`| 14 |
| `solution 2401-2500`| 15 | `solution 2501-2600`| 16 |
| `solution 2601-2700`| 12 | `solution 2701-2800`| 12 |
| `solution 2801-2900`| 16 | `solution 2901-3000`| 13 |
| `solution 3001-3100`| 14 | `solution 3101-3200`| 11 |
| `solution 3201-3300`| 15 | `lc 3301-3800` | 30+ |
| `LCP 专项` | 8 | `LCR 专项` | 25+ |
| `CIQ 专项` | 10+ | `面试精选` | N |
---
## 🏗️ 目录结构
```text
leet-code/
├── include/
│ ├── solution1-100/ # 基础题目集
│ ├── solution101-200/ # 101-200 题
│ ├── solution201-300/ # 201-300 题
│ ├── solution301-400/ # 301-400 题
│ ├── solution401-500/ # 401-500 题
│ ├── solution501-600/ # 501-600 题
│ ├── solution601-700/ # 601-700 题
│ ├── solution701-800/ # 701-800 题
│ ├── solution801-900/ # 801-900 题
│ ├── solution901-1000/ # 901-1000 题
│ ├── solution1001-1100/ # 1001-1100 题
│ ├── solution1101-1200/ # 1101-1200 题
│ ├── solution1201-1300/ # 1201-1300 题
│ ├── solution1301-1400/ # 1301-1400 题
│ ├── solution1401-1500/ # 1401-1500 题
│ ├── solution1501-1600/ # 1501-1600 题
│ ├── solution1601-1700/ # 1601-1700 题
│ ├── solution1701-1800/ # 1701-1800 题
│ ├── solution1801-1900/ # 1801-1900 题
│ ├── solution1901-2000/ # 1901-2000 题
│ ├── solution2001-2100/ # 2001-2100 题
│ ├── solution2101-2200/ # 2101-2200 题
│ ├── solution2201-2300/ # 2201-2300 题
│ ├── solution2301-2400/ # 2301-2400 题
│ ├── solution2401-2500/ # 2401-2500 题
│ ├── solution2501-2600/ # 2501-2600 题
│ ├── solution2601-2700/ # 2601-2700 题
│ ├── solution2701-2800/ # 2701-2800 题
│ ├── solution2801-2900/ # 2801-2900 题
│ ├── solution2901-3000/ # 2901-3000 题
│ ├── solution3001-3100/ # 3001-3100 题
│ ├── solution3101-3200/ # 3101-3200 题
│ ├── solution3201-3300/ # 3201-3300 题
│ ├── lc3301-3400/ # 3301-3400 题
│ ├── lc3401-3500/ # 3401-3500 题
│ ├── lc3501-3600/ # 3501-3600 题
│ ├── lc3601-3700/ # 3601-3700 题
│ ├── lc3701-3800/ # 3701-3800 题
│ ├── code3801-3900/ # 3801-3900 题
│ ├── interview/ # 面试题
│ ├── lcp/ # LCP 专项
│ ├── lcr/ # LCR 专项
│ └── ciq/ # CIQ 专项
├── src/
│ └── main.cpp # 程序入口
├── tests/
│ ├── test14.cpp # 单元测试
│ ├── test70.cpp
│ ├── ...
│ └── test3750.cpp
├── CMakeLists.txt # CMake 配置
└── README.md # 项目文档
```
---
---
## 🛠️ 快速开始
### 环境依赖
- **编译器**: 支持 C++23 的编译器 (GCC 13+, Clang 16+, MSVC 19.36+)
- **构建工具**: CMake 3.10+
### 编译运行
```bash
# 1. 获取源代码
git clone https://gitee.com/bee19940901/leet-code.git && cd leet-code
# 2. 自动化构建
cmake -B build -S .
cmake --build build -j$(nproc)
# 3. 执行测试或主程序
./build/runTests
./build/leet_code
```
---
## 🎨 代码展示
### 💡 核心题解实现 (C++23)
> 以 `14. 最长公共前缀` 为例,展示现代 C++ 的简洁实现。
```cpp
// include/solution1-100/solution14.hpp
#ifndef LEET_CODE_SOLUTION14_HPP
#define LEET_CODE_SOLUTION14_HPP
#include
#include
#include
using namespace std;
string longestCommonPrefix(vector& strs) {
if (strs.empty()) return "";
// 寻找最短字符串作为基准
string str = *min_element(strs.begin(), strs.end(),
[](const string& s1, const string& s2) { return s1.size() < s2.size(); });
for (int j = 0; j < str.size(); ++j) {
for (const auto& s : strs) {
if (s[j] != str[j]) return str.substr(0, j);
}
}
return str;
}
#endif
```
### 🧪 自动化单元测试 (Google Test)
```cpp
// tests/test14.cpp
#include
#include "solution1-100/solution14.hpp"
TEST(Solution14, LongestCommonPrefix) {
vector case1 = {"flower", "flow", "flight"};
EXPECT_EQ(longestCommonPrefix(case1), "fl");
vector case2 = {"dog", "racecar", "car"};
EXPECT_EQ(longestCommonPrefix(case2), "");
}
```
---
## 🤝 贡献指南
我们欢迎任何形式的贡献!如果您有更好的解法或发现了 Bug,请参考以下流程:
1. **Fork** 本仓库并创建您的特性分支。
2. **Implement**:新增题解请按编号存放在 `include/` 下对应的目录。
3. **Test**:为新增题解编写对应的 Google Test 单元测试。
4. **Standard**:确保代码风格与现有项目保持一致。
5. **PR**:提交 Pull Request 并描述您的改进。
---
## 🗺️ 路线图
- [x] 🚀 **算法升级**:持续补全题目,覆盖更多 Hard 难度题目。
- [ ] 📝 **深度解析**:逐步为重点题目添加详细的逻辑注释与复杂度分析。
- [ ] 📊 **解法优化**:利用 C++23 特性重构冗余逻辑,提升代码优雅度。
- [ ] 🧪 **测试完善**:提升单元测试覆盖率,确保边界条件得到充分验证。
---
## 📄 开源协议
本项目基于 **[MIT License](LICENSE)** 开源。
---
**Made with** ♥ **by** @bee19940901