Skip to content

Commit 7a005e6

Browse files
authored
Merge branch 'doocs:main' into main
2 parents ec60f25 + f4c6fcf commit 7a005e6

File tree

8,630 files changed

+451368
-126413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

8,630 files changed

+451368
-126413
lines changed

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# REF: https://spec.editorconfig.org/#supported-pairs
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
# tab_width = 4
9+
# end_of_line = lf
10+
charset = utf-8
11+
# spelling_language = en-US
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
[*.{md}]
16+
trim_trailing_whitespace = false
17+
18+
[*.{go}]
19+
indent_style = tab
20+
21+
[*.{yml,yaml}]
22+
indent_size = 2

.github/workflows/deploy.yml

Lines changed: 82 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: deploy
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
@@ -12,85 +13,118 @@ on:
1213
- lcof/**
1314
- lcci/**
1415
- basic/**
15-
workflow_dispatch:
16-
17-
env:
18-
MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }}
19-
20-
permissions:
21-
contents: write
2216

2317
concurrency:
24-
group: ${{github.workflow}} - ${{github.ref}}
18+
group: ${{ github.workflow }} - ${{ github.ref }}
2519
cancel-in-progress: true
2620

2721
jobs:
28-
deploy:
22+
build:
2923
runs-on: ubuntu-latest
30-
if: github.repository == 'doocs/leetcode'
3124
steps:
32-
- uses: actions/checkout@v4
33-
- uses: actions/checkout@v4
25+
- name: Checkout main branch
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Checkout docs branch
31+
uses: actions/checkout@v4
3432
with:
3533
ref: docs
3634
path: mkdocs
37-
- run: |
38-
mv -f mkdocs/* .
35+
fetch-depth: 0
36+
37+
- name: Sync docs branch content
38+
run: |
39+
rsync -a --remove-source-files --exclude='.git' mkdocs/ ./
40+
rm -rf mkdocs
3941
mv solution/CONTEST_README.md docs/contest.md
4042
mv solution/CONTEST_README_EN.md docs-en/contest.md
43+
4144
- name: Configure Git Credentials
4245
run: |
43-
git config user.name github-actions[bot]
44-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
46+
git config --global user.name github-actions[bot]
47+
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
4548
46-
- uses: actions/setup-python@v5
49+
- name: Setup Python
50+
uses: actions/setup-python@v5
4751
with:
4852
python-version: 3.x
4953

50-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
54+
- name: Restore pip cache
55+
uses: actions/cache@v4
56+
with:
57+
path: ~/.cache/pip
58+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
59+
restore-keys: |
60+
${{ runner.os }}-pip-
5161
52-
- uses: actions/cache@v4
62+
- name: Restore mkdocs-material cache
63+
uses: actions/cache@v4
5364
with:
54-
key: mkdocs-material-${{ env.cache_id }}
5565
path: .cache
66+
key: mkdocs-material-${{ env.cache_id }}
5667
restore-keys: |
5768
mkdocs-material-
58-
69+
5970
- name: Install dependencies
6071
run: |
6172
python3 -m pip install --upgrade pip
6273
python3 -m pip install -r requirements.txt
6374
python3 -m pip install "mkdocs-material[imaging]"
64-
sudo apt-get install pngquant
75+
sudo apt-get install -y pngquant
76+
77+
- name: Set MKDOCS_API_KEYS
78+
run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
6579

66-
- run: |
80+
- name: Build site
81+
run: |
6782
python3 main.py
6883
mkdocs build -f mkdocs.yml
6984
mkdocs build -f mkdocs-en.yml
7085
71-
- name: Deploy
72-
uses: peaceiris/actions-gh-pages@v4
86+
- name: Generate CNAME
87+
run: echo "leetcode.doocs.org" > ./site/CNAME
88+
89+
- name: Commit committer cache to docs branch
90+
if: github.ref == 'refs/heads/main'
91+
env:
92+
GH_REPO: ${{ github.repository }}
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
CACHE_FILE=".git-committers-cache.json"
96+
if [[ ! -f "$CACHE_FILE" ]]; then
97+
echo "Cache file not found; skip commit."
98+
exit 0
99+
fi
100+
101+
echo "Cloning docs branch ..."
102+
git clone --depth 1 --branch docs "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" docs-cache
103+
cp "$CACHE_FILE" docs-cache/
104+
105+
cd docs-cache
106+
git config user.name github-actions[bot]
107+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
108+
109+
git add .git-committers-cache.json
110+
git commit -m "chore: update committer cache [skip ci]" || echo "No changes to commit"
111+
git push origin docs
112+
113+
- name: Upload artifact
114+
uses: actions/upload-pages-artifact@v3
73115
with:
74-
github_token: ${{ secrets.GITHUB_TOKEN }}
75-
publish_dir: ./site
76-
77-
# sync:
78-
# runs-on: ubuntu-latest
79-
# needs: deploy
80-
# if: github.repository == 'doocs/leetcode'
81-
# steps:
82-
# - name: Sync to gitee.com
83-
# uses: wearerequired/git-mirror-action@master
84-
# env:
85-
# SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }}
86-
# with:
87-
# source-repo: [email protected]:doocs/leetcode.git
88-
# destination-repo: [email protected]:Doocs/leetcode.git
89-
90-
# - name: Build Gitee Pages
91-
# uses: yanglbme/gitee-pages-action@main
92-
# with:
93-
# gitee-username: yanglbme
94-
# gitee-password: ${{ secrets.GITEE_PASSWORD }}
95-
# gitee-repo: doocs/leetcode
96-
# branch: gh-pages
116+
path: ./site
117+
118+
deploy:
119+
needs: build
120+
runs-on: ubuntu-latest
121+
permissions:
122+
pages: write
123+
id-token: write
124+
environment:
125+
name: github_pages
126+
url: ${{ steps.deployment.outputs.page_url }}
127+
steps:
128+
- name: Deploy to GitHub Pages
129+
id: deployment
130+
uses: actions/deploy-pages@v4

.github/workflows/pr-add-label.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ on:
44
pull_request_target:
55
types: [opened, edited, reopened, synchronize]
66

7-
concurrency:
8-
group: ${{github.workflow}} - ${{github.event_name}}
9-
cancel-in-progress: true
10-
117
jobs:
128
add-label:
139
permissions:
1410
contents: read
1511
pull-requests: write
1612
runs-on: ubuntu-latest
13+
if: github.repository == 'doocs/leetcode'
1714
steps:
1815
- name: Check PR number
1916
id: pr_number
2017
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
2118

2219
- name: Run add-label Action
23-
uses: thinkasany/pr-label-action@master
20+
uses: actionv/pr-label-action@master
2421
with:
2522
github_token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
2623
pr_number: ${{ env.PR_NUMBER }}

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
.DS_Store
33
.vscode
44
.temp
5-
.cache
5+
.vitepress
66
*.iml
77
__pycache__
88
/node_modules
99
/solution/result.json
1010
/solution/__pycache__
11-
/solution/.env
11+
/solution/.env
12+
.cache
13+
!.cache/plugin/
14+
!.cache/plugin/git-committers/
15+
!.cache/plugin/git-committers/page-authors.json

.husky/commit-msg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
npx --no -- commitlint --edit $1
1+
#!/bin/sh
2+
3+
npx --no -- commitlint --edit $1

.husky/pre-commit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
npx lint-staged --allow-empty $1
1+
#!/bin/sh
2+
3+
npx lint-staged --allow-empty $1

.prettierignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ node_modules/
1616
/solution/0100-0199/0177.Nth Highest Salary/Solution.sql
1717
/solution/0100-0199/0178.Rank Scores/Solution2.sql
1818
/solution/0500-0599/0586.Customer Placing the Largest Number of Orders/Solution2.sql
19-
/solution/1400-1499/1454.Active Users/Solution.sql
2019
/solution/1600-1699/1635.Hopper Company Queries I/Solution.sql
2120
/solution/2100-2199/2118.Build the Equation/Solution.sql
2221
/solution/2100-2199/2175.The Change in Global Rankings/Solution.sql
@@ -25,4 +24,6 @@ node_modules/
2524
/solution/2200-2299/2252.Dynamic Pivoting of a Table/Solution.sql
2625
/solution/2200-2299/2253.Dynamic Unpivoting of a Table/Solution.sql
2726
/solution/3100-3199/3150.Invalid Tweets II/Solution.sql
28-
/solution/3100-3199/3198.Find Cities in Each State/Solution.sql
27+
/solution/3100-3199/3198.Find Cities in Each State/Solution.sql
28+
/solution/3300-3399/3328.Find Cities in Each State II/Solution.sql
29+
/solution/3400-3499/3451.Find Invalid IP Addresses/Solution.sql

README.md

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<p align="center">
2-
<a href="https://github.com/doocs/leetcode"><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/leetcode-doocs.png" alt="LeetCode-GitHub-Doocs"></a>
2+
<a href="https://github.com/doocs/leetcode"><img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/leetcode%40main/images/doocs-leetcode.png" alt="LeetCode-GitHub-Doocs"></a>
33
</p>
44

55
<p align="center">
6-
<a href="https://doocs.github.io/#/?id=how-to-join"><img src="https://img.shields.io/badge/organization-join%20us-42b883?style=flat-square" alt="open-source-organization"></a>
7-
<a href="https://github.com/doocs/leetcode"><img src="https://img.shields.io/badge/langs-Python%20%7C%20Java%20%7C%20C++%20%7C%20Go%20%7C%20TypeScript%20%7C%20Rust%20%7C%20...-red?style=flat-square&color=42b883" alt="languages"></a>
8-
<a href="https://github.com/doocs/leetcode/blob/main/LICENSE"><img src="https://img.shields.io/github/license/doocs/leetcode?color=42b883&style=flat-square" alt="LICENSE"></a><br>
9-
<a href="https://opencollective.com/doocs-leetcode/backers/badge.svg" alt="backers on Open Collective"><img src="https://img.shields.io/opencollective/backers/doocs-leetcode?color=42b883&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
10-
<a href="https://github.com/doocs/leetcode/stargazers"><img src="https://img.shields.io/github/stars/doocs/leetcode?color=42b883&logo=github&style=flat-square" alt="stars"></a>
11-
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode?color=42b883&logo=github&style=flat-square" alt="forks"></a>
12-
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=42b883&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
6+
<a href="https://doocs.github.io/#/?id=how-to-join"><img src="https://img.shields.io/badge/organization-join%20us-4051B5?style=flat-square" alt="open-source-organization"></a>
7+
<a href="https://github.com/doocs/leetcode"><img src="https://img.shields.io/badge/langs-Python%20%7C%20Java%20%7C%20C++%20%7C%20Go%20%7C%20TypeScript%20%7C%20Rust%20%7C%20...-red?style=flat-square&color=4051B5" alt="languages"></a>
8+
<a href="https://github.com/doocs/leetcode/blob/main/LICENSE"><img src="https://img.shields.io/github/license/doocs/leetcode?color=4051B5&style=flat-square" alt="LICENSE"></a><br>
9+
<a href="https://opencollective.com/doocs-leetcode/backers/badge.svg" alt="backers on Open Collective"><img src="https://img.shields.io/opencollective/backers/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
10+
<a href="https://github.com/doocs/leetcode/stargazers"><img src="https://img.shields.io/github/stars/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="stars"></a>
11+
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="forks"></a>
12+
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a><br>
13+
<a href="https://deepwiki.com/doocs/leetcode"><img src="https://img.shields.io/badge/chat%20with-DeepWiki-4051B5?style=flat-square" alt="deepwiki"></a>
1314
</p>
1415

1516
## 介绍
@@ -20,7 +21,7 @@
2021

2122
## 站点
2223

23-
https://doocs.github.io/leetcode
24+
<https://leetcode.doocs.org>
2425

2526
## 算法全解
2627

@@ -189,55 +190,43 @@ https://doocs.github.io/leetcode
189190
1. 进入 leetcode 目录,切换到一个新的分支;
190191
1. 对项目做出一些变更,然后使用 git add、commit、push 等命令将你的本地变更提交到你的远程 GitHub 仓库;
191192
1. 将你的变更以 PR 的形式提交过来,项目的维护人员会在第一时间对你的变更进行 review!
192-
1. 你也可以参考帮助文档 https://help.github.com/cn 了解更多细节。
193+
1. 你也可以参考帮助文档 <https://help.github.com/cn> 了解更多细节。
193194

194-
<p align="center">
195-
  <a href="https://github.com/doocs/leetcode"><img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/leetcode@main/images/how-to-contribute.svg" alt="how-to-contribute"></a>
196-
</p>
195+
<div align="center">
196+
<img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/leetcode%40main/images/pr.svg" width="320px"/>
197+
</div>
197198

198199
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=149001365&machine=basicLinux32gb&location=SoutheastAsia)
199200

200201
## Stars 趋势
201202

202-
<!-- 使用 https://starchart.cc/ 自动刷新 stars 数据,若有问题,可以使用 GitHub Action: starcharts.yml -->
203-
<!-- <a href="https://github.com/doocs/leetcode/stargazers" target="_blank"><img src="https://starchart.cc/doocs/leetcode.svg" alt="Stargazers over time" /></a> -->
204-
205-
<!-- [![Star History Chart](https://api.star-history.com/svg?repos=doocs/leetcode&type=Date)](https://star-history.com/#doocs/leetcode) -->
206-
207203
<a href="https://github.com/doocs/leetcode/stargazers" target="_blank"><img src="./images/starcharts.svg" alt="Stargazers over time" /></a>
208204

205+
<a href="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map?repo_id=149001365&activity=stars" target="_blank" style="display: block" align="center">
206+
<picture>
207+
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?repo_id=149001365&activity=stars&image_size=auto&color_scheme=dark" width="721" height="auto">
208+
<img alt="Star Geographical Distribution of doocs/leetcode" src="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?repo_id=149001365&activity=stars&image_size=auto&color_scheme=light" width="721" height="auto">
209+
</picture>
210+
</a>
211+
209212
## 贡献者
210213

211214
感谢以下所有朋友对本项目的贡献!
212215

213216
<a href="https://github.com/doocs/leetcode/graphs/contributors" target="_blank"><img src="https://contrib.rocks/image?repo=doocs/leetcode&max=500" /></a>
214217

215-
## 赞助者
216-
217-
感谢以下个人、组织对本项目的支持和赞助!
218-
219-
<a href="https://opencollective.com/doocs-leetcode/backers.svg?width=890" target="_blank"><img src="https://opencollective.com/doocs-leetcode/backers.svg?width=890"></a>
220-
221-
<a href="https://opencollective.com/doocs-leetcode/sponsors.svg?width=890" target="_blank"><img src="https://opencollective.com/doocs-leetcode/sponsors.svg?width=890"></a>
222-
223-
> "_You help the developer community practice for interviews, and there is nothing better we could ask for._" -- [Alan Yessenbayev](https://opencollective.com/alan-yessenbayev)
224-
225-
## 推荐者
226-
227-
知名互联网科技博主 [@爱可可-爱生活](https://weibo.com/fly51fly) 微博推荐。
228-
229-
<a href="https://weibo.com/fly51fly" target="_blank"><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/recommender-fly51fly.png"></a>
230-
231218
## 版权
232219

233220
本项目著作权归 [GitHub 开源社区 Doocs](https://github.com/doocs) 所有,商业转载请联系 @yanglbme 获得授权,非商业转载请注明出处。
234221

235-
## 联系我们
222+
## 联系我们 & 支持项目
236223

237224
欢迎各位小伙伴们添加 @yanglbme 的个人微信(微信号:YLB0109),备注 「**leetcode**」。后续我们会创建算法、技术相关的交流群,大家一起交流学习,分享经验,共同进步。
238225

239-
| <img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-yanglbme.png" width="260px" align="left"/> |
240-
| ------------------------------------------------------------------------------------------------------------------------------ |
226+
如果你觉得这个项目对你有帮助,也欢迎通过微信扫码赞赏我们 ☕️~
227+
228+
| <img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/images/qrcode-for-yanglbme.png" width="260px" align="center"/> | <img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/leetcode%40main/images/support1.jpg" width="260px" align="center"/> |
229+
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
241230

242231
## 许可证
243232

0 commit comments

Comments
 (0)