Skip to content

Commit 8aa3218

Browse files
authored
Merge branch 'doocs:main' into main
2 parents 9fc01f6 + 8ec2624 commit 8aa3218

File tree

1,943 files changed

+136828
-63407
lines changed

Some content is hidden

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

1,943 files changed

+136828
-63407
lines changed

.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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pr-add-label
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
jobs:
8+
add-label:
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'doocs/leetcode'
14+
steps:
15+
- name: Check PR number
16+
id: pr_number
17+
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
18+
19+
- name: Run add-label Action
20+
uses: actionv/pr-label-action@master
21+
with:
22+
github_token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
23+
pr_number: ${{ env.PR_NUMBER }}
24+
organize_name: "doocs"
25+
team_name: "leetcode-algorithm"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
.vscode
44
.temp
55
.vitepress
6-
.cache
76
*.iml
87
__pycache__
98
/node_modules
109
/solution/result.json
1110
/solution/__pycache__
1211
/solution/.env
12+
.cache
13+
!.cache/plugin/
14+
!.cache/plugin/git-committers/
15+
!.cache/plugin/git-committers/page-authors.json

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ node_modules/
2626
/solution/3100-3199/3150.Invalid Tweets II/Solution.sql
2727
/solution/3100-3199/3198.Find Cities in Each State/Solution.sql
2828
/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: 22 additions & 18 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

@@ -191,9 +192,18 @@ https://doocs.github.io/leetcode
191192
1. 将你的变更以 PR 的形式提交过来,项目的维护人员会在第一时间对你的变更进行 review!
192193
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+
197+
```mermaid
198+
graph TD;
199+
A[LeetCode 仓库 <br> doocs/leetcode.git] -- 1.Fork(派生) --> B[你的 GitHub 仓库 <br> yourusername/leetcode.git];
200+
B -- 2.Git 克隆 --> C[本地开发环境];
201+
C -- 3.创建新分支并修改代码 --> D[本地修改后的代码];
202+
D -- 4.提交 & 推送到你的仓库 --> B;
203+
B -- 5.提交 Pull Request(合并请求) --> A;
204+
```
205+
206+
</div>
197207

198208
[![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)
199209

@@ -224,12 +234,6 @@ https://doocs.github.io/leetcode
224234

225235
> "_You help the developer community practice for interviews, and there is nothing better we could ask for._" -- [Alan Yessenbayev](https://opencollective.com/alan-yessenbayev)
226236
227-
## 推荐者
228-
229-
知名互联网科技博主 [@爱可可-爱生活](https://weibo.com/fly51fly) 微博推荐。
230-
231-
<a href="https://weibo.com/fly51fly" target="_blank"><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/recommender-fly51fly.png"></a>
232-
233237
## 版权
234238

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

README_EN.md

Lines changed: 25 additions & 15 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
## Introduction
@@ -18,9 +19,9 @@ This project contains solutions for problems from LeetCode, "Coding Interviews (
1819

1920
[中文文档](/README.md)
2021

21-
## Sites
22+
## Site
2223

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

2526
## Solutions
2627

@@ -31,8 +32,8 @@ https://doocs.github.io/leetcode
3132

3233
## JavaScript & Database Practice
3334

34-
- [JavaScript Practice](/solution/JAVASCRIPT_README_EN.md)
35-
- [Database Practice](/solution/DATABASE_README_EN.md)
35+
- [JavaScript](/solution/JAVASCRIPT_README_EN.md)
36+
- [Database](/solution/DATABASE_README_EN.md)
3637

3738
## Topics
3839

@@ -183,9 +184,18 @@ I'm looking for long-term contributors/partners to this repo! Send me [PRs](http
183184
1. Create a pull request with your changes!
184185
1. See [CONTRIBUTING](https://github.com/doocs/.github/blob/main/CONTRIBUTING.md) or [GitHub Help](https://help.github.com/en) for more details.
185186

186-
<p align="center">
187-
  <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>
188-
</p>
187+
<div align="center">
188+
189+
```mermaid
190+
graph TD;
191+
A[LeetCode Repo <br> doocs/leetcode.git] -- 1.Fork --> B[Your GitHub Repo <br> yourusername/leetcode.git];
192+
B -- 2.Git Clone --> C[Local Machine];
193+
C -- 3.Create a New Branch & Make Changes --> D[Modify Code Locally];
194+
D -- 4.Commit & Push to Your Repo --> B;
195+
B -- 5.Create a Pull Request --> A;
196+
```
197+
198+
</div>
189199

190200
[![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=EastUs)
191201

images/doocs-leetcode.png

-33.5 KB
Loading

images/favicon-16x16.png

-933 Bytes
Binary file not shown.

images/favicon-32x32.png

-2.23 KB
Binary file not shown.

images/leetcode-doocs.png

-32.5 KB
Loading

0 commit comments

Comments
 (0)