diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 12bf2f45aa2a5..9cbadf57631dc 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -1,6 +1,7 @@
name: deploy
on:
+ workflow_dispatch:
push:
branches:
- main
@@ -12,85 +13,118 @@ on:
- lcof/**
- lcci/**
- basic/**
- workflow_dispatch:
-
-env:
- MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }}
-
-permissions:
- contents: write
concurrency:
- group: ${{github.workflow}} - ${{github.ref}}
+ group: ${{ github.workflow }} - ${{ github.ref }}
cancel-in-progress: true
jobs:
- deploy:
+ build:
runs-on: ubuntu-latest
- if: github.repository == 'doocs/leetcode'
steps:
- - uses: actions/checkout@v4
- - uses: actions/checkout@v4
+ - name: Checkout main branch
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Checkout docs branch
+ uses: actions/checkout@v4
with:
ref: docs
path: mkdocs
- - run: |
- mv -f mkdocs/* .
+ fetch-depth: 0
+
+ - name: Sync docs branch content
+ run: |
+ rsync -a --remove-source-files --exclude='.git' mkdocs/ ./
+ rm -rf mkdocs
mv solution/CONTEST_README.md docs/contest.md
mv solution/CONTEST_README_EN.md docs-en/contest.md
+
- name: Configure Git Credentials
run: |
- git config user.name github-actions[bot]
- git config user.email 41898282+github-actions[bot]@users.noreply.github.com
+ git config --global user.name github-actions[bot]
+ git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- - uses: actions/setup-python@v5
+ - name: Setup Python
+ uses: actions/setup-python@v5
with:
python-version: 3.x
- - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
+ - name: Restore pip cache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
- - uses: actions/cache@v4
+ - name: Restore mkdocs-material cache
+ uses: actions/cache@v4
with:
- key: mkdocs-material-${{ env.cache_id }}
path: .cache
+ key: mkdocs-material-${{ env.cache_id }}
restore-keys: |
mkdocs-material-
-
+
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install "mkdocs-material[imaging]"
- sudo apt-get install pngquant
+ sudo apt-get install -y pngquant
+
+ - name: Set MKDOCS_API_KEYS
+ run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
- - run: |
+ - name: Build site
+ run: |
python3 main.py
mkdocs build -f mkdocs.yml
mkdocs build -f mkdocs-en.yml
- - name: Deploy
- uses: peaceiris/actions-gh-pages@v4
+ - name: Generate CNAME
+ run: echo "leetcode.doocs.org" > ./site/CNAME
+
+ - name: Commit committer cache to docs branch
+ if: github.ref == 'refs/heads/main'
+ env:
+ GH_REPO: ${{ github.repository }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ CACHE_FILE=".git-committers-cache.json"
+ if [[ ! -f "$CACHE_FILE" ]]; then
+ echo "Cache file not found; skip commit."
+ exit 0
+ fi
+
+ echo "Cloning docs branch ..."
+ git clone --depth 1 --branch docs "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" docs-cache
+ cp "$CACHE_FILE" docs-cache/
+
+ cd docs-cache
+ git config user.name github-actions[bot]
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
+
+ git add .git-committers-cache.json
+ git commit -m "chore: update committer cache [skip ci]" || echo "No changes to commit"
+ git push origin docs
+
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: ./site
-
- # sync:
- # runs-on: ubuntu-latest
- # needs: deploy
- # if: github.repository == 'doocs/leetcode'
- # steps:
- # - name: Sync to gitee.com
- # uses: wearerequired/git-mirror-action@master
- # env:
- # SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }}
- # with:
- # source-repo: git@github.com:doocs/leetcode.git
- # destination-repo: git@gitee.com:Doocs/leetcode.git
-
- # - name: Build Gitee Pages
- # uses: yanglbme/gitee-pages-action@main
- # with:
- # gitee-username: yanglbme
- # gitee-password: ${{ secrets.GITEE_PASSWORD }}
- # gitee-repo: doocs/leetcode
- # branch: gh-pages
\ No newline at end of file
+ path: ./site
+
+ deploy:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ pages: write
+ id-token: write
+ environment:
+ name: github_pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/pr-add-label.yml b/.github/workflows/pr-add-label.yml
index aeadb540a0666..82661e9eb237e 100644
--- a/.github/workflows/pr-add-label.yml
+++ b/.github/workflows/pr-add-label.yml
@@ -4,23 +4,20 @@ on:
pull_request_target:
types: [opened, edited, reopened, synchronize]
-concurrency:
- group: ${{github.workflow}} - ${{github.event_name}}
- cancel-in-progress: true
-
jobs:
add-label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
+ if: github.repository == 'doocs/leetcode'
steps:
- name: Check PR number
id: pr_number
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
- name: Run add-label Action
- uses: thinkasany/pr-label-action@master
+ uses: actionv/pr-label-action@master
with:
github_token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
pr_number: ${{ env.PR_NUMBER }}
diff --git a/.gitignore b/.gitignore
index e8ebbedd5ad1e..521323b59d92d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,10 +3,13 @@
.vscode
.temp
.vitepress
-.cache
*.iml
__pycache__
/node_modules
/solution/result.json
/solution/__pycache__
/solution/.env
+.cache
+!.cache/plugin/
+!.cache/plugin/git-committers/
+!.cache/plugin/git-committers/page-authors.json
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
index 05bf32e478051..47b55e9bdf606 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -25,3 +25,5 @@ node_modules/
/solution/2200-2299/2253.Dynamic Unpivoting of a Table/Solution.sql
/solution/3100-3199/3150.Invalid Tweets II/Solution.sql
/solution/3100-3199/3198.Find Cities in Each State/Solution.sql
+/solution/3300-3399/3328.Find Cities in Each State II/Solution.sql
+/solution/3400-3499/3451.Find Invalid IP Addresses/Solution.sql
diff --git a/README.md b/README.md
index 8431bfcb6e5fe..aa8c9b92c5efa 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,16 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
## 介绍
@@ -20,7 +21,7 @@
## 站点
-https://doocs.github.io/leetcode
+
## 算法全解
@@ -189,55 +190,43 @@ https://doocs.github.io/leetcode
1. 进入 leetcode 目录,切换到一个新的分支;
1. 对项目做出一些变更,然后使用 git add、commit、push 等命令将你的本地变更提交到你的远程 GitHub 仓库;
1. 将你的变更以 PR 的形式提交过来,项目的维护人员会在第一时间对你的变更进行 review!
-1. 你也可以参考帮助文档 https://help.github.com/cn 了解更多细节。
+1. 你也可以参考帮助文档 了解更多细节。
-
-
-
+
+
+
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=149001365&machine=basicLinux32gb&location=SoutheastAsia)
## Stars 趋势
-
-
-
-
-
+
+
+
+
+
+
+
## 贡献者
感谢以下所有朋友对本项目的贡献!
-## 赞助者
-
-感谢以下个人、组织对本项目的支持和赞助!
-
-
-
-
-
-> "_You help the developer community practice for interviews, and there is nothing better we could ask for._" -- [Alan Yessenbayev](https://opencollective.com/alan-yessenbayev)
-
-## 推荐者
-
-知名互联网科技博主 [@爱可可-爱生活](https://weibo.com/fly51fly) 微博推荐。
-
-
-
## 版权
本项目著作权归 [GitHub 开源社区 Doocs](https://github.com/doocs) 所有,商业转载请联系 @yanglbme 获得授权,非商业转载请注明出处。
-## 联系我们
+## 联系我们 & 支持项目
欢迎各位小伙伴们添加 @yanglbme 的个人微信(微信号:YLB0109),备注 「**leetcode**」。后续我们会创建算法、技术相关的交流群,大家一起交流学习,分享经验,共同进步。
-| |
-| ------------------------------------------------------------------------------------------------------------------------------ |
+如果你觉得这个项目对你有帮助,也欢迎通过微信扫码赞赏我们 ☕️~
+
+| | |
+| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
## 许可证
diff --git a/README_EN.md b/README_EN.md
index 7334ac3182bcf..3b461059720a9 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -1,15 +1,16 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
## Introduction
@@ -18,9 +19,9 @@ This project contains solutions for problems from LeetCode, "Coding Interviews (
[中文文档](/README.md)
-## Sites
+## Site
-https://doocs.github.io/leetcode
+https://leetcode.doocs.org/en
## Solutions
@@ -31,8 +32,8 @@ https://doocs.github.io/leetcode
## JavaScript & Database Practice
-- [JavaScript Practice](/solution/JAVASCRIPT_README_EN.md)
-- [Database Practice](/solution/DATABASE_README_EN.md)
+- [JavaScript](/solution/JAVASCRIPT_README_EN.md)
+- [Database](/solution/DATABASE_README_EN.md)
## Topics
@@ -183,40 +184,38 @@ I'm looking for long-term contributors/partners to this repo! Send me [PRs](http
1. Create a pull request with your changes!
1. See [CONTRIBUTING](https://github.com/doocs/.github/blob/main/CONTRIBUTING.md) or [GitHub Help](https://help.github.com/en) for more details.
-
-
-
+
+
+
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=149001365&machine=basicLinux32gb&location=EastUs)
## Stargazers over time
-
-
-
-
+
+
+
+
+
+
+
## Our Top Contributors
This project exists thanks to all the people who contribute.
-## Backers & Sponsors
-
-Thank you to all our backers and sponsors!
-
-
-
-
-
-> "_You help the developer community practice for interviews, and there is nothing better we could ask for._" -- [Alan Yessenbayev](https://opencollective.com/alan-yessenbayev)
-
## Copyright
The copyright of this project belongs to [Doocs](https://github.com/doocs) community. For commercial reprints, please contact [@yanglbme](mailto:contact@yanglibin.info) for authorization. For non-commercial reprints, please indicate the source.
+## Support Us
+
+If you find this project helpful, consider supporting us by buying us a coffee ☕️
+👉 [https://paypal.me/yanglbme](https://paypal.me/yanglbme)
+
## Contact Us
We welcome everyone to add @yanglbme's personal WeChat (WeChat ID: YLB0109), with the note "leetcode". In the future, we will create algorithm and technology related discussion groups, where we can learn and share experiences together, and make progress together.
diff --git a/images/doocs-leetcode.png b/images/doocs-leetcode.png
index 8a7f55f6253a6..a69e814914b16 100644
Binary files a/images/doocs-leetcode.png and b/images/doocs-leetcode.png differ
diff --git a/images/favicon-16x16.png b/images/favicon-16x16.png
deleted file mode 100644
index c846c93f0a389..0000000000000
Binary files a/images/favicon-16x16.png and /dev/null differ
diff --git a/images/favicon-32x32.png b/images/favicon-32x32.png
deleted file mode 100644
index 2d79130a1a393..0000000000000
Binary files a/images/favicon-32x32.png and /dev/null differ
diff --git a/images/leetcode-doocs.png b/images/leetcode-doocs.png
index 616eea1c01815..a69e814914b16 100644
Binary files a/images/leetcode-doocs.png and b/images/leetcode-doocs.png differ
diff --git a/images/pr-en.svg b/images/pr-en.svg
new file mode 100644
index 0000000000000..7465d268ffbf0
--- /dev/null
+++ b/images/pr-en.svg
@@ -0,0 +1 @@
+3.Create a New Branch & Make Changes
4.Commit & Push to Your Repo
LeetCode Repo doocs/leetcode.git
Your GitHub Repo yourusername/leetcode.git
\ No newline at end of file
diff --git a/images/pr.svg b/images/pr.svg
new file mode 100644
index 0000000000000..22e333230e98e
--- /dev/null
+++ b/images/pr.svg
@@ -0,0 +1 @@
+LeetCode 仓库 doocs/leetcode.git
你的 GitHub 仓库 yourusername/leetcode.git
\ No newline at end of file
diff --git a/images/starcharts.svg b/images/starcharts.svg
index 8c2bc6a974300..4e7202135e271 100644
--- a/images/starcharts.svg
+++ b/images/starcharts.svg
@@ -1,4 +1,4 @@
-
+
\n2018-09-25 2019-06-29 2020-04-01 2021-01-03 2021-10-07 2022-07-11 2023-04-14 2024-01-16 2024-10-19 Time 2019-08-05 2020-06-14 2021-04-24 2022-03-04 2023-01-12 2023-11-22 2024-10-01 2025-08-11 Time 0 4000 8000 12000 16000 20000 24000 28000 32000 Stargazers 4400 8800 13200 17500 21900 26300 30700 35000 Stargazers
\ No newline at end of file
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 707 129
+L 708 129
+L 708 129
+L 708 129
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 128
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 127
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 126
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 125
+L 708 124
+L 708 124
+L 708 124
+L 708 124
+L 708 124
+L 708 124
+L 708 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 124
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 123
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 122
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 121
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 709 120
+L 710 120
+L 710 120
+L 710 120
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 119
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 118
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 710 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 711 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 117
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 712 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 116
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 713 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 115
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 114
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 714 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 113
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 715 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 716 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 112
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 111
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 717 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 718 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 110
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 719 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 109
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 720 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 721 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 108
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 722 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 107
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 106
+L 723 105
+L 723 105
+L 723 105
+L 723 105
+L 723 105
+L 723 105
+L 723 105
+L 723 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 105
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 724 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 725 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 104
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 726 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 727 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 103
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 728 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 729 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 102
+L 730 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 731 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 732 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 101
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 733 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 734 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 735 100
+L 736 100
+L 736 100
+L 736 100
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 736 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 737 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 99
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 738 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 739 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 98
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 740 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 741 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 742 97
+L 743 97
+L 743 97
+L 743 97
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 743 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 744 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 745 96
+L 746 96
+L 746 96
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 746 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 747 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 95
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 748 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 94
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 93
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 92
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 91
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 749 90
+L 750 90
+L 750 90
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 89
+L 750 88
+L 750 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 751 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 752 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 753 88
+L 754 88
+L 754 88
+L 754 88
+L 754 88
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 754 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 87
+L 755 86
+L 755 86
+L 755 86
+L 755 86
+L 755 86
+L 755 86
+L 755 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 756 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 86
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 757 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 758 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 85
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 759 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 760 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 761 84
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 762 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 83
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 763 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 764 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 82
+L 765 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 766 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 767 81
+L 768 81
+L 768 81
+L 768 81
+L 768 81
+L 768 81
+L 768 81
+L 768 81
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 768 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 769 80
+L 770 80
+L 770 80
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 770 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 771 79
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 772 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 773 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 774 78
+L 775 78
+L 775 78
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 775 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 776 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 77
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 777 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 778 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 779 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 76
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 780 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 781 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 782 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 75
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 783 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 784 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 785 74
+L 786 74
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 786 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 787 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 73
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 788 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 789 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 790 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 72
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 791 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 792 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 71
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 793 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 794 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 795 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 70
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 796 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 797 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 798 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 69
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 799 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 800 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 68
+L 801 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 802 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 803 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 67
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 804 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 805 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 806 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 66
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 807 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 808 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 65
+L 809 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 810 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 811 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 64
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 812 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 813 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 814 63
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 815 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 62
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 816 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 817 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 61
+L 818 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 819 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 820 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 60
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 821 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 822 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 59
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 823 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 824 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 58
+L 825 57
+L 825 57
+L 825 57
+L 825 57
+L 825 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 826 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 57
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 827 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 828 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 829 56
+L 830 56
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 830 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 831 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 55
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 832 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 833 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 54
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 834 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 835 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 53
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 836 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 837 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 838 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 52
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 839 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 840 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 841 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 51
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 842 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 843 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 50
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 844 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 845 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 846 49
+L 847 49
+L 847 49
+L 847 49
+L 847 49
+L 847 49
+L 847 49
+L 847 49
+L 847 49
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 847 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 848 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 48
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 849 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 850 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 47
+L 851 46
+L 851 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 852 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 853 46
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 854 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 855 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 45
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 856 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 857 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 858 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 44
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 859 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 860 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 861 43
+L 862 43
+L 862 43
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 862 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 863 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 42
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 864 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 865 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 866 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 41
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 867 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 868 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 40
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 869 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 870 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 39
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 871 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 872 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 38
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 873 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 874 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 37
+L 875 36
+L 875 36
+L 875 36
+L 875 36
+L 875 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 876 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 877 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 36
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 878 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 879 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 880 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 35
+L 881 34
+L 881 34
+L 881 34
+L 881 34
+L 881 34
+L 881 34
+L 881 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 882 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 883 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 884 34
+L 885 34
+L 885 34
+L 885 34
+L 885 34
+L 885 34
+L 885 34
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 885 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 886 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 887 33
+L 888 33
+L 888 33
+L 888 33
+L 888 33
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 888 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 889 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 32
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 890 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 891 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 892 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 31
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 893 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 894 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 895 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 30
+L 896 29
+L 896 29
+L 896 29
+L 896 29
+L 896 29
+L 896 29
+L 896 29
+L 896 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 897 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 898 29
+L 899 29
+L 899 29
+L 899 29
+L 899 29
+L 899 29
+L 899 29
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 899 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 900 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 901 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 28
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 902 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 903 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 904 27
+L 905 27
+L 905 27
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 905 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 906 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 26
+L 907 25
+L 907 25
+L 907 25
+L 907 25
+L 907 25
+L 907 25
+L 907 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 908 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 909 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 25
+L 910 24
+L 910 24
+L 910 24
+L 910 24
+L 910 24
+L 910 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 911 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 912 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 24
+L 913 23
+L 913 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 914 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 915 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 916 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 23
+L 917 22
+L 917 22
+L 917 22
+L 917 22
+L 917 22
+L 917 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 918 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 919 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 920 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 22
+L 921 21
+L 921 21
+L 921 21
+L 921 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 922 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 923 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 924 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 925 21
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 926 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 927 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 928 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 929 20
+L 930 20
+L 930 20
+L 930 20
+L 930 20
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 930 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 931 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 932 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 933 19
+L 934 19
+L 934 19
+L 934 19
+L 934 19
+L 934 19
+L 934 19
+L 934 19
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 934 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 935 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 936 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 937 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 18
+L 938 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 939 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 940 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 941 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 942 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 943 17
+L 944 17
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 944 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 945 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 946 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 947 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 16
+L 948 15
+L 948 15
+L 948 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 949 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 15
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14
+L 950 14" style="stroke-width:2;stroke:rgba(129,199,239,1.0);fill:none"/>
\ No newline at end of file
diff --git a/images/support1.jpg b/images/support1.jpg
new file mode 100644
index 0000000000000..5d476dd5a74c4
Binary files /dev/null and b/images/support1.jpg differ
diff --git a/lcci/01.01.Is Unique/README.md b/lcci/01.01.Is Unique/README.md
index e8f0aafbf7165..013967f04e16f 100644
--- a/lcci/01.01.Is Unique/README.md
+++ b/lcci/01.01.Is Unique/README.md
@@ -19,7 +19,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/REA
示例 1:
输入: s = "leetcode"
-输出: false
+输出: false
示例 2:
@@ -56,8 +56,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/REA
class Solution:
def isUnique(self, astr: str) -> bool:
mask = 0
- for c in astr:
- i = ord(c) - ord('a')
+ for i in map(lambda c: ord(c) - ord("a"), astr):
if (mask >> i) & 1:
return False
mask |= 1 << i
diff --git a/lcci/01.01.Is Unique/README_EN.md b/lcci/01.01.Is Unique/README_EN.md
index 86501a1e6e8e5..a63cf58656329 100644
--- a/lcci/01.01.Is Unique/README_EN.md
+++ b/lcci/01.01.Is Unique/README_EN.md
@@ -64,8 +64,7 @@ The time complexity is $O(n)$, where $n$ is the length of the string. The space
class Solution:
def isUnique(self, astr: str) -> bool:
mask = 0
- for c in astr:
- i = ord(c) - ord('a')
+ for i in map(lambda c: ord(c) - ord("a"), astr):
if (mask >> i) & 1:
return False
mask |= 1 << i
diff --git a/lcci/01.01.Is Unique/Solution.py b/lcci/01.01.Is Unique/Solution.py
index 1d63247d2b3a0..06482062b2939 100644
--- a/lcci/01.01.Is Unique/Solution.py
+++ b/lcci/01.01.Is Unique/Solution.py
@@ -1,8 +1,7 @@
class Solution:
def isUnique(self, astr: str) -> bool:
mask = 0
- for c in astr:
- i = ord(c) - ord('a')
+ for i in map(lambda c: ord(c) - ord("a"), astr):
if (mask >> i) & 1:
return False
mask |= 1 << i
diff --git a/lcci/01.02.Check Permutation/README.md b/lcci/01.02.Check Permutation/README.md
index db958faa9953e..786b5c7538b57 100644
--- a/lcci/01.02.Check Permutation/README.md
+++ b/lcci/01.02.Check Permutation/README.md
@@ -93,11 +93,18 @@ class Solution {
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- if (s1.size() != s2.size()) return false;
- int cnt[26] = {0};
- for (char& c : s1) ++cnt[c - 'a'];
- for (char& c : s2)
- if (--cnt[c - 'a'] < 0) return false;
+ if (s1.size() != s2.size()) {
+ return false;
+ }
+ int cnt[26]{};
+ for (char c : s1) {
+ ++cnt[c - 'a'];
+ }
+ for (char c : s2) {
+ if (--cnt[c - 'a'] < 0) {
+ return false;
+ }
+ }
return true;
}
};
@@ -115,8 +122,7 @@ func CheckPermutation(s1 string, s2 string) bool {
cnt[c-'a']++
}
for _, c := range s2 {
- cnt[c-'a']--
- if cnt[c-'a'] < 0 {
+ if cnt[c-'a']--; cnt[c-'a'] < 0 {
return false
}
}
@@ -128,20 +134,18 @@ func CheckPermutation(s1 string, s2 string) bool {
```ts
function CheckPermutation(s1: string, s2: string): boolean {
- const n = s1.length;
- const m = s2.length;
- if (n !== m) {
+ if (s1.length !== s2.length) {
return false;
}
- const map = new Map();
- for (let i = 0; i < n; i++) {
- map.set(s1[i], (map.get(s1[i]) ?? 0) + 1);
- map.set(s2[i], (map.get(s2[i]) ?? 0) - 1);
+ const cnt: Record = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (const v of map.values()) {
- if (v !== 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
}
@@ -150,22 +154,26 @@ function CheckPermutation(s1: string, s2: string): boolean {
#### Rust
```rust
-use std::collections::HashMap;
impl Solution {
pub fn check_permutation(s1: String, s2: String) -> bool {
- let n = s1.len();
- let m = s2.len();
- if n != m {
+ if s1.len() != s2.len() {
return false;
}
- let s1 = s1.as_bytes();
- let s2 = s2.as_bytes();
- let mut map = HashMap::new();
- for i in 0..n {
- *map.entry(s1[i]).or_insert(0) += 1;
- *map.entry(s2[i]).or_insert(0) -= 1;
+
+ let mut cnt = vec![0; 26];
+ for c in s1.chars() {
+ cnt[(c as usize - 'a' as usize)] += 1;
+ }
+
+ for c in s2.chars() {
+ let index = c as usize - 'a' as usize;
+ if cnt[index] == 0 {
+ return false;
+ }
+ cnt[index] -= 1;
}
- map.values().all(|i| *i == 0)
+
+ true
}
}
```
@@ -179,19 +187,18 @@ impl Solution {
* @return {boolean}
*/
var CheckPermutation = function (s1, s2) {
- if (s1.length != s2.length) {
+ if (s1.length !== s2.length) {
return false;
}
- const cnt = new Array(26).fill(0);
- for (let i = 0; i < s1.length; ++i) {
- const j = s1.codePointAt(i) - 'a'.codePointAt(0);
- ++cnt[j];
+ const cnt = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (let i = 0; i < s2.length; ++i) {
- const j = s2.codePointAt(i) - 'a'.codePointAt(0);
- if (--cnt[j] < 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
};
@@ -206,19 +213,18 @@ class Solution {
return false
}
- var cnt = Array(repeating: 0, count: 26)
+ var cnt = [Int](repeating: 0, count: 26)
for char in s1 {
- let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] += 1
+ cnt[Int(char.asciiValue! - Character("a").asciiValue!)] += 1
}
for char in s2 {
let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] -= 1
- if cnt[index] < 0 {
+ if cnt[index] == 0 {
return false
}
+ cnt[index] -= 1
}
return true
@@ -268,8 +274,8 @@ class Solution {
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- sort(s1.begin(), s1.end());
- sort(s2.begin(), s2.end());
+ ranges::sort(s1);
+ ranges::sort(s2);
return s1 == s2;
}
};
@@ -308,6 +314,31 @@ impl Solution {
}
```
+#### JavaScript
+
+```js
+/**
+ * @param {string} s1
+ * @param {string} s2
+ * @return {boolean}
+ */
+var CheckPermutation = function (s1, s2) {
+ return [...s1].sort().join('') === [...s2].sort().join('');
+};
+```
+
+#### Swift
+
+```swift
+class Solution {
+ func CheckPermutation(_ s1: String, _ s2: String) -> Bool {
+ let s1 = s1.sorted()
+ let s2 = s2.sorted()
+ return s1 == s2
+ }
+}
+```
+
diff --git a/lcci/01.02.Check Permutation/README_EN.md b/lcci/01.02.Check Permutation/README_EN.md
index c18cd58477e8d..c582f9a548145 100644
--- a/lcci/01.02.Check Permutation/README_EN.md
+++ b/lcci/01.02.Check Permutation/README_EN.md
@@ -100,11 +100,18 @@ class Solution {
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- if (s1.size() != s2.size()) return false;
- int cnt[26] = {0};
- for (char& c : s1) ++cnt[c - 'a'];
- for (char& c : s2)
- if (--cnt[c - 'a'] < 0) return false;
+ if (s1.size() != s2.size()) {
+ return false;
+ }
+ int cnt[26]{};
+ for (char c : s1) {
+ ++cnt[c - 'a'];
+ }
+ for (char c : s2) {
+ if (--cnt[c - 'a'] < 0) {
+ return false;
+ }
+ }
return true;
}
};
@@ -122,8 +129,7 @@ func CheckPermutation(s1 string, s2 string) bool {
cnt[c-'a']++
}
for _, c := range s2 {
- cnt[c-'a']--
- if cnt[c-'a'] < 0 {
+ if cnt[c-'a']--; cnt[c-'a'] < 0 {
return false
}
}
@@ -135,20 +141,18 @@ func CheckPermutation(s1 string, s2 string) bool {
```ts
function CheckPermutation(s1: string, s2: string): boolean {
- const n = s1.length;
- const m = s2.length;
- if (n !== m) {
+ if (s1.length !== s2.length) {
return false;
}
- const map = new Map();
- for (let i = 0; i < n; i++) {
- map.set(s1[i], (map.get(s1[i]) ?? 0) + 1);
- map.set(s2[i], (map.get(s2[i]) ?? 0) - 1);
+ const cnt: Record = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (const v of map.values()) {
- if (v !== 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
}
@@ -157,22 +161,26 @@ function CheckPermutation(s1: string, s2: string): boolean {
#### Rust
```rust
-use std::collections::HashMap;
impl Solution {
pub fn check_permutation(s1: String, s2: String) -> bool {
- let n = s1.len();
- let m = s2.len();
- if n != m {
+ if s1.len() != s2.len() {
return false;
}
- let s1 = s1.as_bytes();
- let s2 = s2.as_bytes();
- let mut map = HashMap::new();
- for i in 0..n {
- *map.entry(s1[i]).or_insert(0) += 1;
- *map.entry(s2[i]).or_insert(0) -= 1;
+
+ let mut cnt = vec![0; 26];
+ for c in s1.chars() {
+ cnt[(c as usize - 'a' as usize)] += 1;
+ }
+
+ for c in s2.chars() {
+ let index = c as usize - 'a' as usize;
+ if cnt[index] == 0 {
+ return false;
+ }
+ cnt[index] -= 1;
}
- map.values().all(|i| *i == 0)
+
+ true
}
}
```
@@ -186,19 +194,18 @@ impl Solution {
* @return {boolean}
*/
var CheckPermutation = function (s1, s2) {
- if (s1.length != s2.length) {
+ if (s1.length !== s2.length) {
return false;
}
- const cnt = new Array(26).fill(0);
- for (let i = 0; i < s1.length; ++i) {
- const j = s1.codePointAt(i) - 'a'.codePointAt(0);
- ++cnt[j];
+ const cnt = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (let i = 0; i < s2.length; ++i) {
- const j = s2.codePointAt(i) - 'a'.codePointAt(0);
- if (--cnt[j] < 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
};
@@ -213,19 +220,18 @@ class Solution {
return false
}
- var cnt = Array(repeating: 0, count: 26)
+ var cnt = [Int](repeating: 0, count: 26)
for char in s1 {
- let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] += 1
+ cnt[Int(char.asciiValue! - Character("a").asciiValue!)] += 1
}
for char in s2 {
let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] -= 1
- if cnt[index] < 0 {
+ if cnt[index] == 0 {
return false
}
+ cnt[index] -= 1
}
return true
@@ -275,8 +281,8 @@ class Solution {
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- sort(s1.begin(), s1.end());
- sort(s2.begin(), s2.end());
+ ranges::sort(s1);
+ ranges::sort(s2);
return s1 == s2;
}
};
@@ -315,6 +321,31 @@ impl Solution {
}
```
+#### JavaScript
+
+```js
+/**
+ * @param {string} s1
+ * @param {string} s2
+ * @return {boolean}
+ */
+var CheckPermutation = function (s1, s2) {
+ return [...s1].sort().join('') === [...s2].sort().join('');
+};
+```
+
+#### Swift
+
+```swift
+class Solution {
+ func CheckPermutation(_ s1: String, _ s2: String) -> Bool {
+ let s1 = s1.sorted()
+ let s2 = s2.sorted()
+ return s1 == s2
+ }
+}
+```
+
diff --git a/lcci/01.02.Check Permutation/Solution.cpp b/lcci/01.02.Check Permutation/Solution.cpp
index 72808b7ee740c..ff8e6d531810c 100644
--- a/lcci/01.02.Check Permutation/Solution.cpp
+++ b/lcci/01.02.Check Permutation/Solution.cpp
@@ -1,11 +1,18 @@
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- if (s1.size() != s2.size()) return false;
- int cnt[26] = {0};
- for (char& c : s1) ++cnt[c - 'a'];
- for (char& c : s2)
- if (--cnt[c - 'a'] < 0) return false;
+ if (s1.size() != s2.size()) {
+ return false;
+ }
+ int cnt[26]{};
+ for (char c : s1) {
+ ++cnt[c - 'a'];
+ }
+ for (char c : s2) {
+ if (--cnt[c - 'a'] < 0) {
+ return false;
+ }
+ }
return true;
}
-};
\ No newline at end of file
+};
diff --git a/lcci/01.02.Check Permutation/Solution.go b/lcci/01.02.Check Permutation/Solution.go
index 7acd2c2c4bc00..e8fd1ace061de 100644
--- a/lcci/01.02.Check Permutation/Solution.go
+++ b/lcci/01.02.Check Permutation/Solution.go
@@ -7,10 +7,9 @@ func CheckPermutation(s1 string, s2 string) bool {
cnt[c-'a']++
}
for _, c := range s2 {
- cnt[c-'a']--
- if cnt[c-'a'] < 0 {
+ if cnt[c-'a']--; cnt[c-'a'] < 0 {
return false
}
}
return true
-}
\ No newline at end of file
+}
diff --git a/lcci/01.02.Check Permutation/Solution.js b/lcci/01.02.Check Permutation/Solution.js
index 4c0adedaf125b..7aa0ea9b1d428 100644
--- a/lcci/01.02.Check Permutation/Solution.js
+++ b/lcci/01.02.Check Permutation/Solution.js
@@ -4,19 +4,18 @@
* @return {boolean}
*/
var CheckPermutation = function (s1, s2) {
- if (s1.length != s2.length) {
+ if (s1.length !== s2.length) {
return false;
}
- const cnt = new Array(26).fill(0);
- for (let i = 0; i < s1.length; ++i) {
- const j = s1.codePointAt(i) - 'a'.codePointAt(0);
- ++cnt[j];
+ const cnt = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (let i = 0; i < s2.length; ++i) {
- const j = s2.codePointAt(i) - 'a'.codePointAt(0);
- if (--cnt[j] < 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
};
diff --git a/lcci/01.02.Check Permutation/Solution.rs b/lcci/01.02.Check Permutation/Solution.rs
index efe963a0130f2..45cda06875452 100644
--- a/lcci/01.02.Check Permutation/Solution.rs
+++ b/lcci/01.02.Check Permutation/Solution.rs
@@ -1,18 +1,22 @@
-use std::collections::HashMap;
impl Solution {
pub fn check_permutation(s1: String, s2: String) -> bool {
- let n = s1.len();
- let m = s2.len();
- if n != m {
+ if s1.len() != s2.len() {
return false;
}
- let s1 = s1.as_bytes();
- let s2 = s2.as_bytes();
- let mut map = HashMap::new();
- for i in 0..n {
- *map.entry(s1[i]).or_insert(0) += 1;
- *map.entry(s2[i]).or_insert(0) -= 1;
+
+ let mut cnt = vec![0; 26];
+ for c in s1.chars() {
+ cnt[(c as usize - 'a' as usize)] += 1;
}
- map.values().all(|i| *i == 0)
+
+ for c in s2.chars() {
+ let index = c as usize - 'a' as usize;
+ if cnt[index] == 0 {
+ return false;
+ }
+ cnt[index] -= 1;
+ }
+
+ true
}
}
diff --git a/lcci/01.02.Check Permutation/Solution.swift b/lcci/01.02.Check Permutation/Solution.swift
index 7161edfad155c..6bfd2af7416a5 100644
--- a/lcci/01.02.Check Permutation/Solution.swift
+++ b/lcci/01.02.Check Permutation/Solution.swift
@@ -3,22 +3,21 @@ class Solution {
if s1.count != s2.count {
return false
}
-
- var cnt = Array(repeating: 0, count: 26)
-
+
+ var cnt = [Int](repeating: 0, count: 26)
+
for char in s1 {
- let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] += 1
+ cnt[Int(char.asciiValue! - Character("a").asciiValue!)] += 1
}
-
+
for char in s2 {
let index = Int(char.asciiValue! - Character("a").asciiValue!)
- cnt[index] -= 1
- if cnt[index] < 0 {
+ if cnt[index] == 0 {
return false
}
+ cnt[index] -= 1
}
-
+
return true
}
-}
\ No newline at end of file
+}
diff --git a/lcci/01.02.Check Permutation/Solution.ts b/lcci/01.02.Check Permutation/Solution.ts
index 65f0c434d61b9..b6bb1f8822cec 100644
--- a/lcci/01.02.Check Permutation/Solution.ts
+++ b/lcci/01.02.Check Permutation/Solution.ts
@@ -1,18 +1,16 @@
function CheckPermutation(s1: string, s2: string): boolean {
- const n = s1.length;
- const m = s2.length;
- if (n !== m) {
+ if (s1.length !== s2.length) {
return false;
}
- const map = new Map();
- for (let i = 0; i < n; i++) {
- map.set(s1[i], (map.get(s1[i]) ?? 0) + 1);
- map.set(s2[i], (map.get(s2[i]) ?? 0) - 1);
+ const cnt: Record = {};
+ for (const c of s1) {
+ cnt[c] = (cnt[c] || 0) + 1;
}
- for (const v of map.values()) {
- if (v !== 0) {
+ for (const c of s2) {
+ if (!cnt[c]) {
return false;
}
+ cnt[c]--;
}
return true;
}
diff --git a/lcci/01.02.Check Permutation/Solution2.cpp b/lcci/01.02.Check Permutation/Solution2.cpp
index 70c67c68db593..142e3154d5a17 100644
--- a/lcci/01.02.Check Permutation/Solution2.cpp
+++ b/lcci/01.02.Check Permutation/Solution2.cpp
@@ -1,8 +1,8 @@
class Solution {
public:
bool CheckPermutation(string s1, string s2) {
- sort(s1.begin(), s1.end());
- sort(s2.begin(), s2.end());
+ ranges::sort(s1);
+ ranges::sort(s2);
return s1 == s2;
}
-};
\ No newline at end of file
+};
diff --git a/lcci/01.02.Check Permutation/Solution2.js b/lcci/01.02.Check Permutation/Solution2.js
new file mode 100644
index 0000000000000..a5d33c913da3a
--- /dev/null
+++ b/lcci/01.02.Check Permutation/Solution2.js
@@ -0,0 +1,8 @@
+/**
+ * @param {string} s1
+ * @param {string} s2
+ * @return {boolean}
+ */
+var CheckPermutation = function (s1, s2) {
+ return [...s1].sort().join('') === [...s2].sort().join('');
+};
diff --git a/lcci/01.02.Check Permutation/Solution2.swift b/lcci/01.02.Check Permutation/Solution2.swift
new file mode 100644
index 0000000000000..0aef38caddbb4
--- /dev/null
+++ b/lcci/01.02.Check Permutation/Solution2.swift
@@ -0,0 +1,7 @@
+class Solution {
+ func CheckPermutation(_ s1: String, _ s2: String) -> Bool {
+ let s1 = s1.sorted()
+ let s2 = s2.sorted()
+ return s1 == s2
+ }
+}
diff --git a/lcci/01.04.Palindrome Permutation/README.md b/lcci/01.04.Palindrome Permutation/README.md
index 689ccb5841266..b174846e8cd30 100644
--- a/lcci/01.04.Palindrome Permutation/README.md
+++ b/lcci/01.04.Palindrome Permutation/README.md
@@ -94,18 +94,15 @@ public:
```go
func canPermutePalindrome(s string) bool {
- vis := map[rune]bool{}
- cnt := 0
+ cnt := map[rune]int{}
for _, c := range s {
- if vis[c] {
- vis[c] = false
- cnt--
- } else {
- vis[c] = true
- cnt++
- }
+ cnt[c]++
}
- return cnt < 2
+ sum := 0
+ for _, v := range cnt {
+ sum += v & 1
+ }
+ return sum < 2
}
```
@@ -113,34 +110,26 @@ func canPermutePalindrome(s string) bool {
```ts
function canPermutePalindrome(s: string): boolean {
- const set = new Set();
+ const cnt: Record = {};
for (const c of s) {
- if (set.has(c)) {
- set.delete(c);
- } else {
- set.add(c);
- }
+ cnt[c] = (cnt[c] || 0) + 1;
}
- return set.size <= 1;
+ return Object.values(cnt).filter(v => v % 2 === 1).length < 2;
}
```
#### Rust
```rust
-use std::collections::HashSet;
+use std::collections::HashMap;
impl Solution {
pub fn can_permute_palindrome(s: String) -> bool {
- let mut set = HashSet::new();
+ let mut cnt = HashMap::new();
for c in s.chars() {
- if set.contains(&c) {
- set.remove(&c);
- } else {
- set.insert(c);
- }
+ *cnt.entry(c).or_insert(0) += 1;
}
- set.len() <= 1
+ cnt.values().filter(|&&v| v % 2 == 1).count() < 2
}
}
```
@@ -173,7 +162,7 @@ class Solution {
### 方法二:哈希表的另一种实现
-我们用哈希表 $vis$ 存储每个字符是否出现过。若出现过,则从哈希表中删除该字符;否则,将该字符加入哈希表。
+我们用一个哈希表 $\textit{vis}$ 存储每个字符是否出现过。若出现过,则从哈希表中删除该字符;否则,将该字符加入哈希表。
最后判断哈希表中字符的个数是否小于 $2$,若是,则是回文排列。
@@ -231,6 +220,76 @@ public:
};
```
+#### Go
+
+```go
+func canPermutePalindrome(s string) bool {
+ vis := map[rune]bool{}
+ for _, c := range s {
+ if vis[c] {
+ delete(vis, c)
+ } else {
+ vis[c] = true
+ }
+ }
+ return len(vis) < 2
+}
+```
+
+#### TypeScript
+
+```ts
+function canPermutePalindrome(s: string): boolean {
+ const vis = new Set();
+ for (const c of s) {
+ if (vis.has(c)) {
+ vis.delete(c);
+ } else {
+ vis.add(c);
+ }
+ }
+ return vis.size < 2;
+}
+```
+
+#### Rust
+
+```rust
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn can_permute_palindrome(s: String) -> bool {
+ let mut vis = HashSet::new();
+ for c in s.chars() {
+ if vis.contains(&c) {
+ vis.remove(&c);
+ } else {
+ vis.insert(c);
+ }
+ }
+ vis.len() < 2
+ }
+}
+```
+
+#### Swift
+
+```swift
+class Solution {
+ func canPermutePalindrome(_ s: String) -> Bool {
+ var vis = Set()
+ for c in s {
+ if vis.contains(c) {
+ vis.remove(c)
+ } else {
+ vis.insert(c)
+ }
+ }
+ return vis.count < 2
+ }
+}
+```
+
diff --git a/lcci/01.04.Palindrome Permutation/README_EN.md b/lcci/01.04.Palindrome Permutation/README_EN.md
index e942aadc8b522..28d7e6c7c4c02 100644
--- a/lcci/01.04.Palindrome Permutation/README_EN.md
+++ b/lcci/01.04.Palindrome Permutation/README_EN.md
@@ -92,18 +92,15 @@ public:
```go
func canPermutePalindrome(s string) bool {
- vis := map[rune]bool{}
- cnt := 0
+ cnt := map[rune]int{}
for _, c := range s {
- if vis[c] {
- vis[c] = false
- cnt--
- } else {
- vis[c] = true
- cnt++
- }
+ cnt[c]++
}
- return cnt < 2
+ sum := 0
+ for _, v := range cnt {
+ sum += v & 1
+ }
+ return sum < 2
}
```
@@ -111,34 +108,26 @@ func canPermutePalindrome(s string) bool {
```ts
function canPermutePalindrome(s: string): boolean {
- const set = new Set();
+ const cnt: Record = {};
for (const c of s) {
- if (set.has(c)) {
- set.delete(c);
- } else {
- set.add(c);
- }
+ cnt[c] = (cnt[c] || 0) + 1;
}
- return set.size <= 1;
+ return Object.values(cnt).filter(v => v % 2 === 1).length < 2;
}
```
#### Rust
```rust
-use std::collections::HashSet;
+use std::collections::HashMap;
impl Solution {
pub fn can_permute_palindrome(s: String) -> bool {
- let mut set = HashSet::new();
+ let mut cnt = HashMap::new();
for c in s.chars() {
- if set.contains(&c) {
- set.remove(&c);
- } else {
- set.insert(c);
- }
+ *cnt.entry(c).or_insert(0) += 1;
}
- set.len() <= 1
+ cnt.values().filter(|&&v| v % 2 == 1).count() < 2
}
}
```
@@ -229,6 +218,76 @@ public:
};
```
+#### Go
+
+```go
+func canPermutePalindrome(s string) bool {
+ vis := map[rune]bool{}
+ for _, c := range s {
+ if vis[c] {
+ delete(vis, c)
+ } else {
+ vis[c] = true
+ }
+ }
+ return len(vis) < 2
+}
+```
+
+#### TypeScript
+
+```ts
+function canPermutePalindrome(s: string): boolean {
+ const vis = new Set();
+ for (const c of s) {
+ if (vis.has(c)) {
+ vis.delete(c);
+ } else {
+ vis.add(c);
+ }
+ }
+ return vis.size < 2;
+}
+```
+
+#### Rust
+
+```rust
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn can_permute_palindrome(s: String) -> bool {
+ let mut vis = HashSet::new();
+ for c in s.chars() {
+ if vis.contains(&c) {
+ vis.remove(&c);
+ } else {
+ vis.insert(c);
+ }
+ }
+ vis.len() < 2
+ }
+}
+```
+
+#### Swift
+
+```swift
+class Solution {
+ func canPermutePalindrome(_ s: String) -> Bool {
+ var vis = Set()
+ for c in s {
+ if vis.contains(c) {
+ vis.remove(c)
+ } else {
+ vis.insert(c)
+ }
+ }
+ return vis.count < 2
+ }
+}
+```
+
diff --git a/lcci/01.04.Palindrome Permutation/Solution.go b/lcci/01.04.Palindrome Permutation/Solution.go
index 5d156fd33340e..76d5c69a60a52 100644
--- a/lcci/01.04.Palindrome Permutation/Solution.go
+++ b/lcci/01.04.Palindrome Permutation/Solution.go
@@ -1,14 +1,11 @@
-func canPermutePalindrome(s string) bool {
- vis := map[rune]bool{}
- cnt := 0
- for _, c := range s {
- if vis[c] {
- vis[c] = false
- cnt--
- } else {
- vis[c] = true
- cnt++
- }
- }
- return cnt < 2
-}
\ No newline at end of file
+func canPermutePalindrome(s string) bool {
+ cnt := map[rune]int{}
+ for _, c := range s {
+ cnt[c]++
+ }
+ sum := 0
+ for _, v := range cnt {
+ sum += v & 1
+ }
+ return sum < 2
+}
diff --git a/lcci/01.04.Palindrome Permutation/Solution.rs b/lcci/01.04.Palindrome Permutation/Solution.rs
index 0d0e1b07a5e70..895e119d6b604 100644
--- a/lcci/01.04.Palindrome Permutation/Solution.rs
+++ b/lcci/01.04.Palindrome Permutation/Solution.rs
@@ -1,15 +1,11 @@
-use std::collections::HashSet;
+use std::collections::HashMap;
impl Solution {
pub fn can_permute_palindrome(s: String) -> bool {
- let mut set = HashSet::new();
+ let mut cnt = HashMap::new();
for c in s.chars() {
- if set.contains(&c) {
- set.remove(&c);
- } else {
- set.insert(c);
- }
+ *cnt.entry(c).or_insert(0) += 1;
}
- set.len() <= 1
+ cnt.values().filter(|&&v| v % 2 == 1).count() < 2
}
}
diff --git a/lcci/01.04.Palindrome Permutation/Solution.ts b/lcci/01.04.Palindrome Permutation/Solution.ts
index 7bd7505057358..44ba2bc906e83 100644
--- a/lcci/01.04.Palindrome Permutation/Solution.ts
+++ b/lcci/01.04.Palindrome Permutation/Solution.ts
@@ -1,11 +1,7 @@
function canPermutePalindrome(s: string): boolean {
- const set = new Set();
+ const cnt: Record = {};
for (const c of s) {
- if (set.has(c)) {
- set.delete(c);
- } else {
- set.add(c);
- }
+ cnt[c] = (cnt[c] || 0) + 1;
}
- return set.size <= 1;
+ return Object.values(cnt).filter(v => v % 2 === 1).length < 2;
}
diff --git a/lcci/01.04.Palindrome Permutation/Solution2.go b/lcci/01.04.Palindrome Permutation/Solution2.go
new file mode 100644
index 0000000000000..425935647c9f4
--- /dev/null
+++ b/lcci/01.04.Palindrome Permutation/Solution2.go
@@ -0,0 +1,11 @@
+func canPermutePalindrome(s string) bool {
+ vis := map[rune]bool{}
+ for _, c := range s {
+ if vis[c] {
+ delete(vis, c)
+ } else {
+ vis[c] = true
+ }
+ }
+ return len(vis) < 2
+}
diff --git a/lcci/01.04.Palindrome Permutation/Solution2.rs b/lcci/01.04.Palindrome Permutation/Solution2.rs
new file mode 100644
index 0000000000000..5ef83e50f0c4d
--- /dev/null
+++ b/lcci/01.04.Palindrome Permutation/Solution2.rs
@@ -0,0 +1,15 @@
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn can_permute_palindrome(s: String) -> bool {
+ let mut vis = HashSet::new();
+ for c in s.chars() {
+ if vis.contains(&c) {
+ vis.remove(&c);
+ } else {
+ vis.insert(c);
+ }
+ }
+ vis.len() < 2
+ }
+}
diff --git a/lcci/01.04.Palindrome Permutation/Solution2.swift b/lcci/01.04.Palindrome Permutation/Solution2.swift
new file mode 100644
index 0000000000000..993dc395a5b33
--- /dev/null
+++ b/lcci/01.04.Palindrome Permutation/Solution2.swift
@@ -0,0 +1,13 @@
+class Solution {
+ func canPermutePalindrome(_ s: String) -> Bool {
+ var vis = Set()
+ for c in s {
+ if vis.contains(c) {
+ vis.remove(c)
+ } else {
+ vis.insert(c)
+ }
+ }
+ return vis.count < 2
+ }
+}
diff --git a/lcci/01.04.Palindrome Permutation/Solution2.ts b/lcci/01.04.Palindrome Permutation/Solution2.ts
new file mode 100644
index 0000000000000..c72db04c15438
--- /dev/null
+++ b/lcci/01.04.Palindrome Permutation/Solution2.ts
@@ -0,0 +1,11 @@
+function canPermutePalindrome(s: string): boolean {
+ const vis = new Set();
+ for (const c of s) {
+ if (vis.has(c)) {
+ vis.delete(c);
+ } else {
+ vis.add(c);
+ }
+ }
+ return vis.size < 2;
+}
diff --git a/lcci/01.05.One Away/README.md b/lcci/01.05.One Away/README.md
index 471c6c5f9190c..762e58c78330d 100644
--- a/lcci/01.05.One Away/README.md
+++ b/lcci/01.05.One Away/README.md
@@ -43,13 +43,13 @@ second = "pal"
### 方法一:分情况讨论 + 双指针
-我们将字符串 $first$ 和 $second$ 的长度记为 $m$ 和 $n$,不妨设 $m \geq n$。
+我们将字符串 $\textit{first}$ 和 $\textit{second}$ 的长度记为 $m$ 和 $n$,不妨设 $m \geq n$。
接下来分情况讨论:
-- 当 $m - n \gt 1$ 时,$first$ 和 $second$ 无法通过一次编辑得到,返回 `false`;
-- 当 $m = n$ 时,$first$ 和 $second$ 只有在且仅在有且仅有一个字符不同的情况下才能通过一次编辑得到;
-- 当 $m - n = 1$ 时,$first$ 和 $second$ 只有在且仅在 $second$ 是 $first$ 删除一个字符后得到的情况下才能通过一次编辑得到,我们可以使用双指针来实现。
+- 当 $m - n \gt 1$ 时,$\textit{first}$ 和 $\textit{second}$ 无法通过一次编辑得到,返回 `false`;
+- 当 $m = n$ 时,$\textit{first}$ 和 $\textit{second}$ 只有在且仅在有且仅有一个字符不同的情况下才能通过一次编辑得到;
+- 当 $m - n = 1$ 时,$\textit{first}$ 和 $\textit{second}$ 只有在且仅在 $\textit{second}$ 是 $\textit{first}$ 删除一个字符后得到的情况下才能通过一次编辑得到,我们可以使用双指针来实现。
时间复杂度 $O(n)$,其中 $n$ 为字符串长度。空间复杂度 $O(1)$。
diff --git a/lcci/01.05.One Away/README_EN.md b/lcci/01.05.One Away/README_EN.md
index a0703be7fa38b..98a164c97d143 100644
--- a/lcci/01.05.One Away/README_EN.md
+++ b/lcci/01.05.One Away/README_EN.md
@@ -50,15 +50,15 @@ second = "pal"
-### Solution 1: Case Discussion + Two Pointers
+### Solution 1: Case Analysis + Two Pointers
-We denote the lengths of strings $first$ and $second$ as $m$ and $n$, respectively, where $m \geq n$.
+Let the lengths of the strings $\textit{first}$ and $\textit{second}$ be $m$ and $n$, respectively. Assume $m \geq n$.
-Next, we discuss different cases:
+Next, we discuss the following cases:
-- When $m - n > 1$, $first$ and $second$ cannot be obtained through a single edit, so we return `false`.
-- When $m = n$, $first$ and $second$ can only be obtained through a single edit if and only if exactly one character is different.
-- When $m - n = 1$, $first$ and $second$ can only be obtained through a single edit if and only if $second$ is obtained by deleting one character from $first$. We can use two pointers to implement this.
+- When $m - n \gt 1$, $\textit{first}$ and $\textit{second}$ cannot be made equal with one edit, so return `false`;
+- When $m = n$, $\textit{first}$ and $\textit{second}$ can be made equal with one edit only if there is exactly one different character;
+- When $m - n = 1$, $\textit{first}$ and $\textit{second}$ can be made equal with one edit only if $\textit{second}$ is obtained by deleting one character from $\textit{first}$. We can use two pointers to achieve this.
The time complexity is $O(n)$, where $n$ is the length of the string. The space complexity is $O(1)$.
diff --git a/lcci/01.06.Compress String/README.md b/lcci/01.06.Compress String/README.md
index 829eb7d532a86..2a08b263e8ae5 100644
--- a/lcci/01.06.Compress String/README.md
+++ b/lcci/01.06.Compress String/README.md
@@ -62,22 +62,6 @@ class Solution:
return min(S, t, key=len)
```
-#### Python3
-
-```python
-class Solution:
- def compressString(self, S: str) -> str:
- t = []
- i, n = 0, len(S)
- while i < n:
- j = i + 1
- while j < n and S[j] == S[i]:
- j += 1
- t.append(S[i] + str(j - i))
- i = j
- return min(S, "".join(t), key=len)
-```
-
#### Java
```java
diff --git a/lcci/01.06.Compress String/README_EN.md b/lcci/01.06.Compress String/README_EN.md
index 10346e225a81c..e1a9f55e5b8a0 100644
--- a/lcci/01.06.Compress String/README_EN.md
+++ b/lcci/01.06.Compress String/README_EN.md
@@ -69,22 +69,6 @@ class Solution:
return min(S, t, key=len)
```
-#### Python3
-
-```python
-class Solution:
- def compressString(self, S: str) -> str:
- t = []
- i, n = 0, len(S)
- while i < n:
- j = i + 1
- while j < n and S[j] == S[i]:
- j += 1
- t.append(S[i] + str(j - i))
- i = j
- return min(S, "".join(t), key=len)
-```
-
#### Java
```java
diff --git a/lcci/01.06.Compress String/Solution2.py b/lcci/01.06.Compress String/Solution2.py
deleted file mode 100644
index d3bc1c1aab18d..0000000000000
--- a/lcci/01.06.Compress String/Solution2.py
+++ /dev/null
@@ -1,11 +0,0 @@
-class Solution:
- def compressString(self, S: str) -> str:
- t = []
- i, n = 0, len(S)
- while i < n:
- j = i + 1
- while j < n and S[j] == S[i]:
- j += 1
- t.append(S[i] + str(j - i))
- i = j
- return min(S, "".join(t), key=len)
diff --git a/lcci/01.07.Rotate Matrix/README.md b/lcci/01.07.Rotate Matrix/README.md
index 2d6b196c90198..d9b2763c2a520 100644
--- a/lcci/01.07.Rotate Matrix/README.md
+++ b/lcci/01.07.Rotate Matrix/README.md
@@ -64,9 +64,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.07.Rotate%20Matrix
### 方法一:原地翻转
-根据题目要求,我们实际上需要将 $matrix[i][j]$ 旋转至 $matrix[j][n - i - 1]$。
+根据题目要求,我们实际上需要将 $\text{matrix}[i][j]$ 旋转至 $\text{matrix}[j][n - i - 1]$。
-我们可以先对矩阵进行上下翻转,即 $matrix[i][j]$ 和 $matrix[n - i - 1][j]$ 进行交换,然后再对矩阵进行主对角线翻转,即 $matrix[i][j]$ 和 $matrix[j][i]$ 进行交换。这样就能将 $matrix[i][j]$ 旋转至 $matrix[j][n - i - 1]$ 了。
+我们可以先对矩阵进行上下翻转,即 $\text{matrix}[i][j]$ 和 $\text{matrix}[n - i - 1][j]$ 进行交换,然后再对矩阵进行主对角线翻转,即 $\text{matrix}[i][j]$ 和 $\text{matrix}[j][i]$ 进行交换。这样就能将 $\text{matrix}[i][j]$ 旋转至 $\text{matrix}[j][n - i - 1]$ 了。
时间复杂度 $O(n^2)$,其中 $n$ 是矩阵的边长。空间复杂度 $O(1)$。
diff --git a/lcci/01.07.Rotate Matrix/README_EN.md b/lcci/01.07.Rotate Matrix/README_EN.md
index f093f2a013175..8a1f0badd0a68 100644
--- a/lcci/01.07.Rotate Matrix/README_EN.md
+++ b/lcci/01.07.Rotate Matrix/README_EN.md
@@ -92,11 +92,11 @@ Rotate the matrix in place. It becomes:
-### Solution 1: In-place Rotation
+### Solution 1: In-Place Rotation
-According to the problem requirements, we actually need to rotate $matrix[i][j]$ to $matrix[j][n - i - 1]$.
+According to the problem requirements, we need to rotate $\text{matrix}[i][j]$ to $\text{matrix}[j][n - i - 1]$.
-We can first flip the matrix upside down, that is, swap $matrix[i][j]$ and $matrix[n - i - 1][j]$, and then flip the matrix along the main diagonal, that is, swap $matrix[i][j]$ and $matrix[j][i]$. This way, we can rotate $matrix[i][j]$ to $matrix[j][n - i - 1]$.
+We can first flip the matrix upside down, i.e., swap $\text{matrix}[i][j]$ with $\text{matrix}[n - i - 1][j]$, and then flip the matrix along the main diagonal, i.e., swap $\text{matrix}[i][j]$ with $\text{matrix}[j][i]$. This will rotate $\text{matrix}[i][j]$ to $\text{matrix}[j][n - i - 1]$.
The time complexity is $O(n^2)$, where $n$ is the side length of the matrix. The space complexity is $O(1)$.
diff --git a/lcci/02.08.Linked List Cycle/README.md b/lcci/02.08.Linked List Cycle/README.md
index 37fbe9f8e76a7..facce4bf87406 100644
--- a/lcci/02.08.Linked List Cycle/README.md
+++ b/lcci/02.08.Linked List Cycle/README.md
@@ -44,6 +44,8 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/02.08.Linked%20List%2
+#### Python3
+
```python
# Definition for singly-linked list.
# class ListNode:
@@ -66,6 +68,8 @@ class Solution:
return ans
```
+#### Java
+
```java
/**
* Definition for singly-linked list.
@@ -98,6 +102,8 @@ public class Solution {
}
```
+#### C++
+
```cpp
/**
* Definition for singly-linked list.
@@ -129,6 +135,8 @@ public:
};
```
+#### Go
+
```go
/**
* Definition for singly-linked list.
@@ -155,6 +163,8 @@ func detectCycle(head *ListNode) *ListNode {
}
```
+#### TypeScript
+
```ts
/**
* Definition for singly-linked list.
@@ -186,6 +196,8 @@ function detectCycle(head: ListNode | null): ListNode | null {
}
```
+#### JavaScript
+
```js
/**
* Definition for singly-linked list.
@@ -217,6 +229,8 @@ var detectCycle = function (head) {
};
```
+#### Swift
+
```swift
/*
* public class ListNode {
@@ -251,4 +265,8 @@ class Solution {
}
```
+
+
+
+
diff --git a/lcci/04.01.Route Between Nodes/README.md b/lcci/04.01.Route Between Nodes/README.md
index 1846da42fc412..2e3b752f019a6 100644
--- a/lcci/04.01.Route Between Nodes/README.md
+++ b/lcci/04.01.Route Between Nodes/README.md
@@ -126,7 +126,7 @@ public:
for (auto& e : graph) {
g[e[0]].push_back(e[1]);
}
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) -> bool {
if (i == target) {
return true;
}
diff --git a/lcci/04.01.Route Between Nodes/README_EN.md b/lcci/04.01.Route Between Nodes/README_EN.md
index 5205c2f35b5a8..e32e55d20a57b 100644
--- a/lcci/04.01.Route Between Nodes/README_EN.md
+++ b/lcci/04.01.Route Between Nodes/README_EN.md
@@ -134,7 +134,7 @@ public:
for (auto& e : graph) {
g[e[0]].push_back(e[1]);
}
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) -> bool {
if (i == target) {
return true;
}
diff --git a/lcci/04.01.Route Between Nodes/Solution.cpp b/lcci/04.01.Route Between Nodes/Solution.cpp
index 915c3ca91ac20..0863689995365 100644
--- a/lcci/04.01.Route Between Nodes/Solution.cpp
+++ b/lcci/04.01.Route Between Nodes/Solution.cpp
@@ -6,7 +6,7 @@ class Solution {
for (auto& e : graph) {
g[e[0]].push_back(e[1]);
}
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) -> bool {
if (i == target) {
return true;
}
@@ -23,4 +23,4 @@ class Solution {
};
return dfs(start);
}
-};
\ No newline at end of file
+};
diff --git a/lcci/04.02.Minimum Height Tree/README.md b/lcci/04.02.Minimum Height Tree/README.md
index 3fccbc8f93760..f0c126c3a85ec 100644
--- a/lcci/04.02.Minimum Height Tree/README.md
+++ b/lcci/04.02.Minimum Height Tree/README.md
@@ -103,7 +103,7 @@ class Solution {
class Solution {
public:
TreeNode* sortedArrayToBST(vector& nums) {
- function dfs = [&](int l, int r) -> TreeNode* {
+ auto dfs = [&](this auto&& dfs, int l, int r) -> TreeNode* {
if (l > r) {
return nullptr;
}
diff --git a/lcci/04.02.Minimum Height Tree/README_EN.md b/lcci/04.02.Minimum Height Tree/README_EN.md
index 40f629d61050d..84724a048b2f1 100644
--- a/lcci/04.02.Minimum Height Tree/README_EN.md
+++ b/lcci/04.02.Minimum Height Tree/README_EN.md
@@ -24,19 +24,19 @@ Given sorted array: [-10,-3,0,5,9],
-One possible answer is: [0,-3,9,-10,null,5],which represents the following tree:
+One possible answer is: [0,-3,9,-10,null,5],which represents the following tree:
- 0
+ 0
- / \
+ / \
- -3 9
+ -3 9
- / /
+ / /
- -10 5
+ -10 5
@@ -127,7 +127,7 @@ class Solution {
class Solution {
public:
TreeNode* sortedArrayToBST(vector& nums) {
- function dfs = [&](int l, int r) -> TreeNode* {
+ auto dfs = [&](this auto&& dfs, int l, int r) -> TreeNode* {
if (l > r) {
return nullptr;
}
diff --git a/lcci/04.02.Minimum Height Tree/Solution.cpp b/lcci/04.02.Minimum Height Tree/Solution.cpp
index ecfbdddbae48a..66a66d1f27bb7 100644
--- a/lcci/04.02.Minimum Height Tree/Solution.cpp
+++ b/lcci/04.02.Minimum Height Tree/Solution.cpp
@@ -10,7 +10,7 @@
class Solution {
public:
TreeNode* sortedArrayToBST(vector& nums) {
- function dfs = [&](int l, int r) -> TreeNode* {
+ auto dfs = [&](this auto&& dfs, int l, int r) -> TreeNode* {
if (l > r) {
return nullptr;
}
@@ -19,4 +19,4 @@ class Solution {
};
return dfs(0, nums.size() - 1);
}
-};
\ No newline at end of file
+};
diff --git a/lcci/04.08.First Common Ancestor/README.md b/lcci/04.08.First Common Ancestor/README.md
index d7a9fb878e8e4..c51706d069e79 100644
--- a/lcci/04.08.First Common Ancestor/README.md
+++ b/lcci/04.08.First Common Ancestor/README.md
@@ -22,7 +22,13 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/04.08.First%20Common%
-### 方法一
+### 方法一:递归
+
+我们首先判断根节点是否为空,或者根节点是否等于 $\textit{p}$ 或 $\textit{q}$,如果是的话,直接返回根节点。
+
+然后递归地对左右子树进行查找,分别得到 $\textit{left}$ 和 $\textit{right}$。如果 $\textit{left}$ 和 $\textit{right}$ 都不为空,说明 $\textit{p}$ 和 $\textit{q}$ 分别在左右子树中,那么根节点就是最近公共祖先。否则,如果 $\textit{left}$ 和 $\textit{right}$ 中有一个为空,说明 $\textit{p}$ 和 $\textit{q}$ 都在非空的子树中,那么非空的子树的根节点就是最近公共祖先。
+
+时间复杂度 $O(n)$,空间复杂度 $O(n)$。其中 $n$ 是二叉树中节点的数目。
@@ -41,11 +47,11 @@ class Solution:
def lowestCommonAncestor(
self, root: TreeNode, p: TreeNode, q: TreeNode
) -> TreeNode:
- if root is None or root == p or root == q:
+ if root is None or root in [p, q]:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
- return right if left is None else (left if right is None else root)
+ return root if left and right else left or right
```
#### Java
@@ -72,6 +78,84 @@ class Solution {
}
```
+#### C++
+
+```cpp
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+ TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
+ if (!root || root == p || root == q) {
+ return root;
+ }
+ TreeNode* left = lowestCommonAncestor(root->left, p, q);
+ TreeNode* right = lowestCommonAncestor(root->right, p, q);
+ return left && right ? root : (left ? left : right);
+ }
+};
+```
+
+#### Go
+
+```go
+/**
+ * Definition for a binary tree node.
+ * type TreeNode struct {
+ * Val int
+ * Left *TreeNode
+ * Right *TreeNode
+ * }
+ */
+func lowestCommonAncestor(root *TreeNode, p *TreeNode, q *TreeNode) *TreeNode {
+ if root == nil || root == p || root == q {
+ return root
+ }
+ left := lowestCommonAncestor(root.Left, p, q)
+ right := lowestCommonAncestor(root.Right, p, q)
+ if left == nil {
+ return right
+ }
+ if right == nil {
+ return left
+ }
+ return root
+}
+```
+
+#### JavaScript
+
+```js
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @param {TreeNode} p
+ * @param {TreeNode} q
+ * @return {TreeNode}
+ */
+var lowestCommonAncestor = function (root, p, q) {
+ if (!root || root === p || root === q) {
+ return root;
+ }
+ const left = lowestCommonAncestor(root.left, p, q);
+ const right = lowestCommonAncestor(root.right, p, q);
+ return left && right ? root : left || right;
+};
+```
+
#### Swift
```swift
diff --git a/lcci/04.08.First Common Ancestor/README_EN.md b/lcci/04.08.First Common Ancestor/README_EN.md
index 8df95cc286a11..e500060c3e04c 100644
--- a/lcci/04.08.First Common Ancestor/README_EN.md
+++ b/lcci/04.08.First Common Ancestor/README_EN.md
@@ -69,7 +69,13 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/04.08.First%20Common%
-### Solution 1
+### Solution 1: Recursion
+
+First, we check if the root node is null or if the root node is equal to $\textit{p}$ or $\textit{q}$. If so, we return the root node directly.
+
+Then, we recursively search the left and right subtrees to get $\textit{left}$ and $\textit{right}$, respectively. If both $\textit{left}$ and $\textit{right}$ are not null, it means $\textit{p}$ and $\textit{q}$ are in the left and right subtrees, respectively, so the root node is the lowest common ancestor. Otherwise, if either $\textit{left}$ or $\textit{right}$ is null, it means both $\textit{p}$ and $\textit{q}$ are in the non-null subtree, so the root node of the non-null subtree is the lowest common ancestor.
+
+The time complexity is $O(n)$, and the space complexity is $O(n)$. Here, $n$ is the number of nodes in the binary tree.
@@ -88,11 +94,11 @@ class Solution:
def lowestCommonAncestor(
self, root: TreeNode, p: TreeNode, q: TreeNode
) -> TreeNode:
- if root is None or root == p or root == q:
+ if root is None or root in [p, q]:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
- return right if left is None else (left if right is None else root)
+ return root if left and right else left or right
```
#### Java
@@ -119,6 +125,84 @@ class Solution {
}
```
+#### C++
+
+```cpp
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+ TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
+ if (!root || root == p || root == q) {
+ return root;
+ }
+ TreeNode* left = lowestCommonAncestor(root->left, p, q);
+ TreeNode* right = lowestCommonAncestor(root->right, p, q);
+ return left && right ? root : (left ? left : right);
+ }
+};
+```
+
+#### Go
+
+```go
+/**
+ * Definition for a binary tree node.
+ * type TreeNode struct {
+ * Val int
+ * Left *TreeNode
+ * Right *TreeNode
+ * }
+ */
+func lowestCommonAncestor(root *TreeNode, p *TreeNode, q *TreeNode) *TreeNode {
+ if root == nil || root == p || root == q {
+ return root
+ }
+ left := lowestCommonAncestor(root.Left, p, q)
+ right := lowestCommonAncestor(root.Right, p, q)
+ if left == nil {
+ return right
+ }
+ if right == nil {
+ return left
+ }
+ return root
+}
+```
+
+#### JavaScript
+
+```js
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @param {TreeNode} p
+ * @param {TreeNode} q
+ * @return {TreeNode}
+ */
+var lowestCommonAncestor = function (root, p, q) {
+ if (!root || root === p || root === q) {
+ return root;
+ }
+ const left = lowestCommonAncestor(root.left, p, q);
+ const right = lowestCommonAncestor(root.right, p, q);
+ return left && right ? root : left || right;
+};
+```
+
#### Swift
```swift
diff --git a/lcci/04.08.First Common Ancestor/Solution.cpp b/lcci/04.08.First Common Ancestor/Solution.cpp
new file mode 100644
index 0000000000000..1cd5e13570f9b
--- /dev/null
+++ b/lcci/04.08.First Common Ancestor/Solution.cpp
@@ -0,0 +1,20 @@
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+ TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
+ if (!root || root == p || root == q) {
+ return root;
+ }
+ TreeNode* left = lowestCommonAncestor(root->left, p, q);
+ TreeNode* right = lowestCommonAncestor(root->right, p, q);
+ return left && right ? root : (left ? left : right);
+ }
+};
diff --git a/lcci/04.08.First Common Ancestor/Solution.go b/lcci/04.08.First Common Ancestor/Solution.go
new file mode 100644
index 0000000000000..b2668e2c48820
--- /dev/null
+++ b/lcci/04.08.First Common Ancestor/Solution.go
@@ -0,0 +1,22 @@
+/**
+ * Definition for a binary tree node.
+ * type TreeNode struct {
+ * Val int
+ * Left *TreeNode
+ * Right *TreeNode
+ * }
+ */
+func lowestCommonAncestor(root *TreeNode, p *TreeNode, q *TreeNode) *TreeNode {
+ if root == nil || root == p || root == q {
+ return root
+ }
+ left := lowestCommonAncestor(root.Left, p, q)
+ right := lowestCommonAncestor(root.Right, p, q)
+ if left == nil {
+ return right
+ }
+ if right == nil {
+ return left
+ }
+ return root
+}
diff --git a/lcci/04.08.First Common Ancestor/Solution.js b/lcci/04.08.First Common Ancestor/Solution.js
new file mode 100644
index 0000000000000..cba4ad1be11d1
--- /dev/null
+++ b/lcci/04.08.First Common Ancestor/Solution.js
@@ -0,0 +1,21 @@
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @param {TreeNode} p
+ * @param {TreeNode} q
+ * @return {TreeNode}
+ */
+var lowestCommonAncestor = function (root, p, q) {
+ if (!root || root === p || root === q) {
+ return root;
+ }
+ const left = lowestCommonAncestor(root.left, p, q);
+ const right = lowestCommonAncestor(root.right, p, q);
+ return left && right ? root : left || right;
+};
diff --git a/lcci/04.08.First Common Ancestor/Solution.py b/lcci/04.08.First Common Ancestor/Solution.py
index 1622fd413d1b0..ebd8bb7f1f46b 100644
--- a/lcci/04.08.First Common Ancestor/Solution.py
+++ b/lcci/04.08.First Common Ancestor/Solution.py
@@ -10,8 +10,8 @@ class Solution:
def lowestCommonAncestor(
self, root: TreeNode, p: TreeNode, q: TreeNode
) -> TreeNode:
- if root is None or root == p or root == q:
+ if root is None or root in [p, q]:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
- return right if left is None else (left if right is None else root)
+ return root if left and right else left or right
diff --git a/lcci/04.12.Paths with Sum/README.md b/lcci/04.12.Paths with Sum/README.md
index 5ff30a2c961e5..6f0a4bcdfbffc 100644
--- a/lcci/04.12.Paths with Sum/README.md
+++ b/lcci/04.12.Paths with Sum/README.md
@@ -70,15 +70,13 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/04.12.Paths%20with%20
```python
# Definition for a binary tree node.
# class TreeNode:
-# def __init__(self, x):
-# self.val = x
-# self.left = None
-# self.right = None
-
-
+# def __init__(self, val=0, left=None, right=None):
+# self.val = val
+# self.left = left
+# self.right = right
class Solution:
- def pathSum(self, root: TreeNode, sum: int) -> int:
- def dfs(root: TreeNode, s: int):
+ def pathSum(self, root: Optional[TreeNode], sum: int) -> int:
+ def dfs(root: Optional[TreeNode], s: int) -> int:
if root is None:
return 0
s += root.val
@@ -145,9 +143,8 @@ class Solution {
class Solution {
public:
int pathSum(TreeNode* root, int sum) {
- unordered_map cnt;
- cnt[0] = 1;
- function dfs = [&](TreeNode* root, long long s) {
+ unordered_map cnt{{0, 1}};
+ auto dfs = [&](this auto&& dfs, TreeNode* root, long long s) -> int {
if (!root) {
return 0;
}
@@ -285,43 +282,40 @@ impl Solution {
#### Swift
```swift
-/* class TreeNode {
-* var val: Int
-* var left: TreeNode?
-* var right: TreeNode?
-*
-* init(_ val: Int, _ left: TreeNode? = nil, _ right: TreeNode? = nil) {
-* self.val = val
-* self.left = left
-* self.right = right
-* }
-* }
-*/
-
+/**
+ * Definition for a binary tree node.
+ * public class TreeNode {
+ * public var val: Int
+ * public var left: TreeNode?
+ * public var right: TreeNode?
+ * public init() { self.val = 0; self.left = nil; self.right = nil; }
+ * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+ * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+ * self.val = val
+ * self.left = left
+ * self.right = right
+ * }
+ * }
+ */
class Solution {
- private var cnt: [Int: Int] = [:]
- private var target: Int = 0
-
func pathSum(_ root: TreeNode?, _ sum: Int) -> Int {
- cnt[0] = 1
- target = sum
- return dfs(root, 0)
+ var cnt: [Int: Int] = [0: 1]
- }
+ func dfs(_ root: TreeNode?, _ s: Int) -> Int {
+ guard let root = root else { return 0 }
- private func dfs(_ root: TreeNode?, _ s: Int) -> Int {
- guard let root = root else {
- return 0
- }
- let newSum = s + root.val
- let ans = cnt[newSum - target, default: 0]
+ var s = s + root.val
+ var ans = cnt[s - sum, default: 0]
- cnt[newSum, default: 0] += 1
- let leftPaths = dfs(root.left, newSum)
- let rightPaths = dfs(root.right, newSum)
- cnt[newSum, default: 0] -= 1
+ cnt[s, default: 0] += 1
+ ans += dfs(root.left, s)
+ ans += dfs(root.right, s)
+ cnt[s, default: 0] -= 1
- return ans + leftPaths + rightPaths
+ return ans
+ }
+
+ return dfs(root, 0)
}
}
```
diff --git a/lcci/04.12.Paths with Sum/README_EN.md b/lcci/04.12.Paths with Sum/README_EN.md
index e2b797b3c05f5..179134478b763 100644
--- a/lcci/04.12.Paths with Sum/README_EN.md
+++ b/lcci/04.12.Paths with Sum/README_EN.md
@@ -83,15 +83,13 @@ The time complexity is $O(n)$, and the space complexity is $O(n)$. Here, $n$ is
```python
# Definition for a binary tree node.
# class TreeNode:
-# def __init__(self, x):
-# self.val = x
-# self.left = None
-# self.right = None
-
-
+# def __init__(self, val=0, left=None, right=None):
+# self.val = val
+# self.left = left
+# self.right = right
class Solution:
- def pathSum(self, root: TreeNode, sum: int) -> int:
- def dfs(root: TreeNode, s: int):
+ def pathSum(self, root: Optional[TreeNode], sum: int) -> int:
+ def dfs(root: Optional[TreeNode], s: int) -> int:
if root is None:
return 0
s += root.val
@@ -158,9 +156,8 @@ class Solution {
class Solution {
public:
int pathSum(TreeNode* root, int sum) {
- unordered_map cnt;
- cnt[0] = 1;
- function dfs = [&](TreeNode* root, long long s) {
+ unordered_map cnt{{0, 1}};
+ auto dfs = [&](this auto&& dfs, TreeNode* root, long long s) -> int {
if (!root) {
return 0;
}
@@ -298,42 +295,40 @@ impl Solution {
#### Swift
```swift
-/* class TreeNode {
-* var val: Int
-* var left: TreeNode?
-* var right: TreeNode?
-*
-* init(_ val: Int, _ left: TreeNode? = nil, _ right: TreeNode? = nil) {
-* self.val = val
-* self.left = left
-* self.right = right
-* }
-* }
-*/
-
+/**
+ * Definition for a binary tree node.
+ * public class TreeNode {
+ * public var val: Int
+ * public var left: TreeNode?
+ * public var right: TreeNode?
+ * public init() { self.val = 0; self.left = nil; self.right = nil; }
+ * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+ * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+ * self.val = val
+ * self.left = left
+ * self.right = right
+ * }
+ * }
+ */
class Solution {
- private var cnt: [Int: Int] = [:]
- private var target: Int = 0
-
func pathSum(_ root: TreeNode?, _ sum: Int) -> Int {
- cnt[0] = 1
- target = sum
- return dfs(root, 0)
- }
+ var cnt: [Int: Int] = [0: 1]
- private func dfs(_ root: TreeNode?, _ s: Int) -> Int {
- guard let root = root else {
- return 0
- }
- let newSum = s + root.val
- let ans = cnt[newSum - target, default: 0]
+ func dfs(_ root: TreeNode?, _ s: Int) -> Int {
+ guard let root = root else { return 0 }
+
+ var s = s + root.val
+ var ans = cnt[s - sum, default: 0]
+
+ cnt[s, default: 0] += 1
+ ans += dfs(root.left, s)
+ ans += dfs(root.right, s)
+ cnt[s, default: 0] -= 1
- cnt[newSum, default: 0] += 1
- let leftPaths = dfs(root.left, newSum)
- let rightPaths = dfs(root.right, newSum)
- cnt[newSum, default: 0] -= 1
+ return ans
+ }
- return ans + leftPaths + rightPaths
+ return dfs(root, 0)
}
}
```
diff --git a/lcci/04.12.Paths with Sum/Solution.cpp b/lcci/04.12.Paths with Sum/Solution.cpp
index 72e43d0c492c0..9095a6ab905d9 100644
--- a/lcci/04.12.Paths with Sum/Solution.cpp
+++ b/lcci/04.12.Paths with Sum/Solution.cpp
@@ -10,9 +10,8 @@
class Solution {
public:
int pathSum(TreeNode* root, int sum) {
- unordered_map cnt;
- cnt[0] = 1;
- function dfs = [&](TreeNode* root, long long s) {
+ unordered_map cnt{{0, 1}};
+ auto dfs = [&](this auto&& dfs, TreeNode* root, long long s) -> int {
if (!root) {
return 0;
}
@@ -26,4 +25,4 @@ class Solution {
};
return dfs(root, 0);
}
-};
\ No newline at end of file
+};
diff --git a/lcci/04.12.Paths with Sum/Solution.py b/lcci/04.12.Paths with Sum/Solution.py
index 096e03e07552b..25e2179fe9ddc 100644
--- a/lcci/04.12.Paths with Sum/Solution.py
+++ b/lcci/04.12.Paths with Sum/Solution.py
@@ -1,14 +1,12 @@
# Definition for a binary tree node.
# class TreeNode:
-# def __init__(self, x):
-# self.val = x
-# self.left = None
-# self.right = None
-
-
+# def __init__(self, val=0, left=None, right=None):
+# self.val = val
+# self.left = left
+# self.right = right
class Solution:
- def pathSum(self, root: TreeNode, sum: int) -> int:
- def dfs(root: TreeNode, s: int):
+ def pathSum(self, root: Optional[TreeNode], sum: int) -> int:
+ def dfs(root: Optional[TreeNode], s: int) -> int:
if root is None:
return 0
s += root.val
diff --git a/lcci/04.12.Paths with Sum/Solution.swift b/lcci/04.12.Paths with Sum/Solution.swift
index cf1cbe9a5b95e..ad6fb0b161171 100644
--- a/lcci/04.12.Paths with Sum/Solution.swift
+++ b/lcci/04.12.Paths with Sum/Solution.swift
@@ -1,38 +1,36 @@
-/* class TreeNode {
-* var val: Int
-* var left: TreeNode?
-* var right: TreeNode?
-*
-* init(_ val: Int, _ left: TreeNode? = nil, _ right: TreeNode? = nil) {
-* self.val = val
-* self.left = left
-* self.right = right
-* }
-* }
-*/
-
+/**
+ * Definition for a binary tree node.
+ * public class TreeNode {
+ * public var val: Int
+ * public var left: TreeNode?
+ * public var right: TreeNode?
+ * public init() { self.val = 0; self.left = nil; self.right = nil; }
+ * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+ * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+ * self.val = val
+ * self.left = left
+ * self.right = right
+ * }
+ * }
+ */
class Solution {
- private var cnt: [Int: Int] = [:]
- private var target: Int = 0
-
func pathSum(_ root: TreeNode?, _ sum: Int) -> Int {
- cnt[0] = 1
- target = sum
- return dfs(root, 0)
- }
+ var cnt: [Int: Int] = [0: 1]
+
+ func dfs(_ root: TreeNode?, _ s: Int) -> Int {
+ guard let root = root else { return 0 }
- private func dfs(_ root: TreeNode?, _ s: Int) -> Int {
- guard let root = root else {
- return 0
+ var s = s + root.val
+ var ans = cnt[s - sum, default: 0]
+
+ cnt[s, default: 0] += 1
+ ans += dfs(root.left, s)
+ ans += dfs(root.right, s)
+ cnt[s, default: 0] -= 1
+
+ return ans
}
- let newSum = s + root.val
- let ans = cnt[newSum - target, default: 0]
-
- cnt[newSum, default: 0] += 1
- let leftPaths = dfs(root.left, newSum)
- let rightPaths = dfs(root.right, newSum)
- cnt[newSum, default: 0] -= 1
-
- return ans + leftPaths + rightPaths
+
+ return dfs(root, 0)
}
-}
\ No newline at end of file
+}
diff --git a/lcci/05.03.Reverse Bits/README.md b/lcci/05.03.Reverse Bits/README.md
index cbec7bc2a611d..fad13598cbc1b 100644
--- a/lcci/05.03.Reverse Bits/README.md
+++ b/lcci/05.03.Reverse Bits/README.md
@@ -134,13 +134,13 @@ function reverseBits(num: number): number {
class Solution {
func reverseBits(_ num: Int) -> Int {
var ans = 0
- var countZeros = 0
+ var cnt = 0
var j = 0
for i in 0..<32 {
- countZeros += (num >> i & 1 ^ 1)
- while countZeros > 1 {
- countZeros -= (num >> j & 1 ^ 1)
+ cnt += (num >> i & 1 ^ 1)
+ while cnt > 1 {
+ cnt -= (num >> j & 1 ^ 1)
j += 1
}
ans = max(ans, i - j + 1)
diff --git a/lcci/05.03.Reverse Bits/README_EN.md b/lcci/05.03.Reverse Bits/README_EN.md
index eb68a91114262..a9c88a668e959 100644
--- a/lcci/05.03.Reverse Bits/README_EN.md
+++ b/lcci/05.03.Reverse Bits/README_EN.md
@@ -142,13 +142,13 @@ function reverseBits(num: number): number {
class Solution {
func reverseBits(_ num: Int) -> Int {
var ans = 0
- var countZeros = 0
+ var cnt = 0
var j = 0
for i in 0..<32 {
- countZeros += (num >> i & 1 ^ 1)
- while countZeros > 1 {
- countZeros -= (num >> j & 1 ^ 1)
+ cnt += (num >> i & 1 ^ 1)
+ while cnt > 1 {
+ cnt -= (num >> j & 1 ^ 1)
j += 1
}
ans = max(ans, i - j + 1)
diff --git a/lcci/05.03.Reverse Bits/Solution.swift b/lcci/05.03.Reverse Bits/Solution.swift
index da1c7fe2acf4a..0bd69d4893f51 100644
--- a/lcci/05.03.Reverse Bits/Solution.swift
+++ b/lcci/05.03.Reverse Bits/Solution.swift
@@ -1,13 +1,13 @@
class Solution {
func reverseBits(_ num: Int) -> Int {
var ans = 0
- var countZeros = 0
+ var cnt = 0
var j = 0
for i in 0..<32 {
- countZeros += (num >> i & 1 ^ 1)
- while countZeros > 1 {
- countZeros -= (num >> j & 1 ^ 1)
+ cnt += (num >> i & 1 ^ 1)
+ while cnt > 1 {
+ cnt -= (num >> j & 1 ^ 1)
j += 1
}
ans = max(ans, i - j + 1)
diff --git a/lcci/08.02.Robot in a Grid/README.md b/lcci/08.02.Robot in a Grid/README.md
index cc1bf9f600664..8b60835e73b0c 100644
--- a/lcci/08.02.Robot in a Grid/README.md
+++ b/lcci/08.02.Robot in a Grid/README.md
@@ -15,7 +15,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.02.Robot%20in%20a%
设想有个机器人坐在一个网格的左上角,网格 r 行 c 列。机器人只能向下或向右移动,但不能走到一些被禁止的网格(有障碍物)。设计一种算法,寻找机器人从左上角移动到右下角的路径。
+

+
网格中的障碍物和空位置分别用 1
和 0
来表示。
返回一条可行的路径,路径由经过的网格的行号和列号组成。左上角为 0 行 0 列。
示例 1:
@@ -26,7 +28,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.02.Robot%20in%20a%
[0,0,0 ]
]
输出: [[0,0],[0,1],[0,2],[1,2],[2,2]]
-解释:
+解释:
输入中标粗的位置即为输出表示的路径,即
0行0列(左上角) -> 0行1列 -> 0行2列 -> 1行2列 -> 2行2列(右下角)
说明: r 和 c 的值均不超过 100。
@@ -107,7 +109,7 @@ public:
int m = obstacleGrid.size();
int n = obstacleGrid[0].size();
vector> ans;
- function dfs = [&](int i, int j) -> bool {
+ auto dfs = [&](this auto&& dfs, int i, int j) -> bool {
if (i >= m || j >= n || obstacleGrid[i][j] == 1) {
return false;
}
diff --git a/lcci/08.02.Robot in a Grid/README_EN.md b/lcci/08.02.Robot in a Grid/README_EN.md
index 3ba14cfdcd585..bb37b1b1bf1d9 100644
--- a/lcci/08.02.Robot in a Grid/README_EN.md
+++ b/lcci/08.02.Robot in a Grid/README_EN.md
@@ -15,7 +15,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.02.Robot%20in%20a%
Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are "off limits" such that the robot cannot step on them. Design an algorithm to find a path for the robot from the top left to the bottom right.
+

+
"off limits" and empty grid are represented by 1
and 0
respectively.
Return a valid path, consisting of row number and column number of grids in the path.
Example 1:
@@ -116,7 +118,7 @@ public:
int m = obstacleGrid.size();
int n = obstacleGrid[0].size();
vector> ans;
- function dfs = [&](int i, int j) -> bool {
+ auto dfs = [&](this auto&& dfs, int i, int j) -> bool {
if (i >= m || j >= n || obstacleGrid[i][j] == 1) {
return false;
}
diff --git a/lcci/08.02.Robot in a Grid/Solution.cpp b/lcci/08.02.Robot in a Grid/Solution.cpp
index e9657e05ef757..f7daef341d833 100644
--- a/lcci/08.02.Robot in a Grid/Solution.cpp
+++ b/lcci/08.02.Robot in a Grid/Solution.cpp
@@ -4,7 +4,7 @@ class Solution {
int m = obstacleGrid.size();
int n = obstacleGrid[0].size();
vector> ans;
- function dfs = [&](int i, int j) -> bool {
+ auto dfs = [&](this auto&& dfs, int i, int j) -> bool {
if (i >= m || j >= n || obstacleGrid[i][j] == 1) {
return false;
}
@@ -18,4 +18,4 @@ class Solution {
};
return dfs(0, 0) ? ans : vector>();
}
-};
\ No newline at end of file
+};
diff --git a/lcci/08.06.Hanota/README.md b/lcci/08.06.Hanota/README.md
index 04efe8940d384..b5dc3d3966adc 100644
--- a/lcci/08.06.Hanota/README.md
+++ b/lcci/08.06.Hanota/README.md
@@ -91,7 +91,7 @@ class Solution {
class Solution {
public:
void hanota(vector& A, vector& B, vector& C) {
- function&, vector&, vector&)> dfs = [&](int n, vector& a, vector& b, vector& c) {
+ auto dfs = [&](this auto&& dfs, int n, vector& a, vector& b, vector& c) {
if (n == 1) {
c.push_back(a.back());
a.pop_back();
diff --git a/lcci/08.06.Hanota/README_EN.md b/lcci/08.06.Hanota/README_EN.md
index 6d4243950efb0..3f52664c584e4 100644
--- a/lcci/08.06.Hanota/README_EN.md
+++ b/lcci/08.06.Hanota/README_EN.md
@@ -98,7 +98,7 @@ class Solution {
class Solution {
public:
void hanota(vector& A, vector& B, vector& C) {
- function&, vector&, vector&)> dfs = [&](int n, vector& a, vector& b, vector& c) {
+ auto dfs = [&](this auto&& dfs, int n, vector& a, vector& b, vector& c) {
if (n == 1) {
c.push_back(a.back());
a.pop_back();
diff --git a/lcci/08.06.Hanota/Solution.cpp b/lcci/08.06.Hanota/Solution.cpp
index 7cf7ad9647324..3b5b8d483ce8b 100644
--- a/lcci/08.06.Hanota/Solution.cpp
+++ b/lcci/08.06.Hanota/Solution.cpp
@@ -1,7 +1,7 @@
class Solution {
public:
void hanota(vector& A, vector& B, vector& C) {
- function&, vector&, vector&)> dfs = [&](int n, vector& a, vector& b, vector& c) {
+ auto dfs = [&](this auto&& dfs, int n, vector& a, vector& b, vector& c) {
if (n == 1) {
c.push_back(a.back());
a.pop_back();
@@ -14,4 +14,4 @@ class Solution {
};
dfs(A.size(), A, B, C);
}
-};
\ No newline at end of file
+};
diff --git a/lcci/08.07.Permutation I/README.md b/lcci/08.07.Permutation I/README.md
index 34a783fde5bac..9d3e78c2da0d4 100644
--- a/lcci/08.07.Permutation I/README.md
+++ b/lcci/08.07.Permutation I/README.md
@@ -45,7 +45,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.07.Permutation%20I
### 方法一:DFS(回溯)
-我们设计一个函数 $dfs(i)$ 表示已经填完了前 $i$ 个位置,现在需要填第 $i+1$ 个位置。枚举所有可能的字符,如果这个字符没有被填过,就填入这个字符,然后继续填下一个位置,直到填完所有的位置。
+我们设计一个函数 $\textit{dfs}(i)$ 表示已经填完了前 $i$ 个位置,现在需要填第 $i+1$ 个位置。枚举所有可能的字符,如果这个字符没有被填过,就填入这个字符,然后继续填下一个位置,直到填完所有的位置。
时间复杂度 $O(n \times n!)$,其中 $n$ 是字符串的长度。一共有 $n!$ 个排列,每个排列需要 $O(n)$ 的时间来构造。
@@ -57,22 +57,20 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.07.Permutation%20I
class Solution:
def permutation(self, S: str) -> List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
for j, c in enumerate(S):
- if vis[j]:
- continue
- vis[j] = True
- t.append(c)
- dfs(i + 1)
- t.pop()
- vis[j] = False
+ if not vis[j]:
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
+ ans = []
n = len(S)
vis = [False] * n
- ans = []
- t = []
+ t = list(S)
dfs(0)
return ans
```
@@ -82,30 +80,31 @@ class Solution:
```java
class Solution {
private char[] s;
- private boolean[] vis = new boolean['z' + 1];
+ private char[] t;
+ private boolean[] vis;
private List ans = new ArrayList<>();
- private StringBuilder t = new StringBuilder();
public String[] permutation(String S) {
s = S.toCharArray();
+ int n = s.length;
+ vis = new boolean[n];
+ t = new char[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == s.length) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (char c : s) {
- if (vis[c]) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[c] = true;
- t.append(c);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[c] = false;
}
}
}
@@ -119,51 +118,49 @@ public:
vector permutation(string S) {
int n = S.size();
vector vis(n);
+ string t = S;
vector ans;
- string t;
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) {
if (i >= n) {
- ans.push_back(t);
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j]) {
- continue;
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(S[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
return ans;
}
};
+
```
#### Go
```go
func permutation(S string) (ans []string) {
- t := []byte{}
- vis := make([]bool, len(S))
+ t := []byte(S)
+ n := len(t)
+ vis := make([]bool, n)
var dfs func(int)
dfs = func(i int) {
- if i >= len(S) {
+ if i >= n {
ans = append(ans, string(t))
return
}
for j := range S {
- if vis[j] {
- continue
+ if !vis[j] {
+ vis[j] = true
+ t[i] = S[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, S[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
@@ -178,7 +175,7 @@ function permutation(S: string): string[] {
const n = S.length;
const vis: boolean[] = Array(n).fill(false);
const ans: string[] = [];
- const t: string[] = [];
+ const t: string[] = Array(n).fill('');
const dfs = (i: number) => {
if (i >= n) {
ans.push(t.join(''));
@@ -189,9 +186,8 @@ function permutation(S: string): string[] {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
@@ -211,7 +207,7 @@ var permutation = function (S) {
const n = S.length;
const vis = Array(n).fill(false);
const ans = [];
- const t = [];
+ const t = Array(n).fill('');
const dfs = i => {
if (i >= n) {
ans.push(t.join(''));
@@ -222,9 +218,8 @@ var permutation = function (S) {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
@@ -237,33 +232,30 @@ var permutation = function (S) {
```swift
class Solution {
- private var s: [Character] = []
- private var vis: [Bool] = Array(repeating: false, count: 128)
- private var ans: [String] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- s = Array(S)
- dfs(0)
- return ans
- }
-
- private func dfs(_ i: Int) {
- if i == s.count {
- ans.append(t)
- return
- }
- for c in s {
- let index = Int(c.asciiValue!)
- if vis[index] {
- continue
+ var ans: [String] = []
+ let s = Array(S)
+ var t = s
+ var vis = Array(repeating: false, count: s.count)
+ let n = s.count
+
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0.. List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
for j, c in enumerate(S):
- if vis[j]:
- continue
- vis[j] = True
- t.append(c)
- dfs(i + 1)
- t.pop()
- vis[j] = False
+ if not vis[j]:
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
+ ans = []
n = len(S)
vis = [False] * n
- ans = []
- t = []
+ t = list(S)
dfs(0)
return ans
```
@@ -88,30 +86,31 @@ class Solution:
```java
class Solution {
private char[] s;
- private boolean[] vis = new boolean['z' + 1];
+ private char[] t;
+ private boolean[] vis;
private List ans = new ArrayList<>();
- private StringBuilder t = new StringBuilder();
public String[] permutation(String S) {
s = S.toCharArray();
+ int n = s.length;
+ vis = new boolean[n];
+ t = new char[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == s.length) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (char c : s) {
- if (vis[c]) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[c] = true;
- t.append(c);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[c] = false;
}
}
}
@@ -125,22 +124,20 @@ public:
vector permutation(string S) {
int n = S.size();
vector vis(n);
+ string t = S;
vector ans;
- string t;
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) {
if (i >= n) {
- ans.push_back(t);
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j]) {
- continue;
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(S[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
@@ -153,23 +150,22 @@ public:
```go
func permutation(S string) (ans []string) {
- t := []byte{}
- vis := make([]bool, len(S))
+ t := []byte(S)
+ n := len(t)
+ vis := make([]bool, n)
var dfs func(int)
dfs = func(i int) {
- if i >= len(S) {
+ if i >= n {
ans = append(ans, string(t))
return
}
for j := range S {
- if vis[j] {
- continue
+ if !vis[j] {
+ vis[j] = true
+ t[i] = S[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, S[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
@@ -184,7 +180,7 @@ function permutation(S: string): string[] {
const n = S.length;
const vis: boolean[] = Array(n).fill(false);
const ans: string[] = [];
- const t: string[] = [];
+ const t: string[] = Array(n).fill('');
const dfs = (i: number) => {
if (i >= n) {
ans.push(t.join(''));
@@ -195,9 +191,8 @@ function permutation(S: string): string[] {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
@@ -217,7 +212,7 @@ var permutation = function (S) {
const n = S.length;
const vis = Array(n).fill(false);
const ans = [];
- const t = [];
+ const t = Array(n).fill('');
const dfs = i => {
if (i >= n) {
ans.push(t.join(''));
@@ -228,9 +223,8 @@ var permutation = function (S) {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
@@ -243,33 +237,30 @@ var permutation = function (S) {
```swift
class Solution {
- private var s: [Character] = []
- private var vis: [Bool] = Array(repeating: false, count: 128)
- private var ans: [String] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- s = Array(S)
- dfs(0)
- return ans
- }
-
- private func dfs(_ i: Int) {
- if i == s.count {
- ans.append(t)
- return
- }
- for c in s {
- let index = Int(c.asciiValue!)
- if vis[index] {
- continue
+ var ans: [String] = []
+ let s = Array(S)
+ var t = s
+ var vis = Array(repeating: false, count: s.count)
+ let n = s.count
+
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0.. permutation(string S) {
int n = S.size();
vector vis(n);
+ string t = S;
vector ans;
- string t;
- function dfs = [&](int i) {
+ auto dfs = [&](this auto&& dfs, int i) {
if (i >= n) {
- ans.push_back(t);
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j]) {
- continue;
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(S[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
return ans;
}
-};
\ No newline at end of file
+};
diff --git a/lcci/08.07.Permutation I/Solution.go b/lcci/08.07.Permutation I/Solution.go
index 20d5c55fded5f..1f84fb692481e 100644
--- a/lcci/08.07.Permutation I/Solution.go
+++ b/lcci/08.07.Permutation I/Solution.go
@@ -1,23 +1,22 @@
func permutation(S string) (ans []string) {
- t := []byte{}
- vis := make([]bool, len(S))
+ t := []byte(S)
+ n := len(t)
+ vis := make([]bool, n)
var dfs func(int)
dfs = func(i int) {
- if i >= len(S) {
+ if i >= n {
ans = append(ans, string(t))
return
}
for j := range S {
- if vis[j] {
- continue
+ if !vis[j] {
+ vis[j] = true
+ t[i] = S[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, S[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
return
-}
\ No newline at end of file
+}
diff --git a/lcci/08.07.Permutation I/Solution.java b/lcci/08.07.Permutation I/Solution.java
index 896ed99f9d1ea..f65456f945759 100644
--- a/lcci/08.07.Permutation I/Solution.java
+++ b/lcci/08.07.Permutation I/Solution.java
@@ -1,29 +1,30 @@
class Solution {
private char[] s;
- private boolean[] vis = new boolean['z' + 1];
+ private char[] t;
+ private boolean[] vis;
private List ans = new ArrayList<>();
- private StringBuilder t = new StringBuilder();
public String[] permutation(String S) {
s = S.toCharArray();
+ int n = s.length;
+ vis = new boolean[n];
+ t = new char[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == s.length) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (char c : s) {
- if (vis[c]) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j]) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[c] = true;
- t.append(c);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[c] = false;
}
}
-}
\ No newline at end of file
+}
diff --git a/lcci/08.07.Permutation I/Solution.js b/lcci/08.07.Permutation I/Solution.js
index f1dcb5d98f69f..c18ebd79c017d 100644
--- a/lcci/08.07.Permutation I/Solution.js
+++ b/lcci/08.07.Permutation I/Solution.js
@@ -6,7 +6,7 @@ var permutation = function (S) {
const n = S.length;
const vis = Array(n).fill(false);
const ans = [];
- const t = [];
+ const t = Array(n).fill('');
const dfs = i => {
if (i >= n) {
ans.push(t.join(''));
@@ -17,9 +17,8 @@ var permutation = function (S) {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
diff --git a/lcci/08.07.Permutation I/Solution.py b/lcci/08.07.Permutation I/Solution.py
index 537c2f0484bb7..7e64e799f8691 100644
--- a/lcci/08.07.Permutation I/Solution.py
+++ b/lcci/08.07.Permutation I/Solution.py
@@ -1,21 +1,19 @@
class Solution:
def permutation(self, S: str) -> List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
for j, c in enumerate(S):
- if vis[j]:
- continue
- vis[j] = True
- t.append(c)
- dfs(i + 1)
- t.pop()
- vis[j] = False
+ if not vis[j]:
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
+ ans = []
n = len(S)
vis = [False] * n
- ans = []
- t = []
+ t = list(S)
dfs(0)
return ans
diff --git a/lcci/08.07.Permutation I/Solution.swift b/lcci/08.07.Permutation I/Solution.swift
index 48803e420ab09..33a987fc012d9 100644
--- a/lcci/08.07.Permutation I/Solution.swift
+++ b/lcci/08.07.Permutation I/Solution.swift
@@ -1,30 +1,27 @@
class Solution {
- private var s: [Character] = []
- private var vis: [Bool] = Array(repeating: false, count: 128)
- private var ans: [String] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- s = Array(S)
- dfs(0)
- return ans
- }
+ var ans: [String] = []
+ let s = Array(S)
+ var t = s
+ var vis = Array(repeating: false, count: s.count)
+ let n = s.count
- private func dfs(_ i: Int) {
- if i == s.count {
- ans.append(t)
- return
- }
- for c in s {
- let index = Int(c.asciiValue!)
- if vis[index] {
- continue
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0.. {
if (i >= n) {
ans.push(t.join(''));
@@ -13,9 +13,8 @@ function permutation(S: string): string[] {
continue;
}
vis[j] = true;
- t.push(S[j]);
+ t[i] = S[j];
dfs(i + 1);
- t.pop();
vis[j] = false;
}
};
diff --git a/lcci/08.08.Permutation II/README.md b/lcci/08.08.Permutation II/README.md
index 90b72d44fb2f1..936fb1b9d90cf 100644
--- a/lcci/08.08.Permutation II/README.md
+++ b/lcci/08.08.Permutation II/README.md
@@ -39,12 +39,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.08.Permutation%20I
我们可以先对字符串按照字符进行排序,这样就可以将重复的字符放在一起,方便我们进行去重。
-然后,我们设计一个函数 $dfs(i)$,表示当前需要填写第 $i$ 个位置的字符。函数的具体实现如下:
+然后,我们设计一个函数 $\textit{dfs}(i)$,表示当前需要填写第 $i$ 个位置的字符。函数的具体实现如下:
- 如果 $i = n$,说明我们已经填写完毕,将当前排列加入答案数组中,然后返回。
-- 否则,我们枚举第 $i$ 个位置的字符 $s[j]$,其中 $j$ 的范围是 $[0, n - 1]$。我们需要保证 $s[j]$ 没有被使用过,并且与前面枚举的字符不同,这样才能保证当前排列不重复。如果满足条件,我们就可以填写 $s[j]$,并继续递归地填写下一个位置,即调用 $dfs(i + 1)$。在递归调用结束后,我们需要将 $s[j]$ 标记为未使用,以便于进行后面的枚举。
+- 否则,我们枚举第 $i$ 个位置的字符 $\textit{s}[j]$,其中 $j$ 的范围是 $[0, n - 1]$。我们需要保证 $\textit{s}[j]$ 没有被使用过,并且与前面枚举的字符不同,这样才能保证当前排列不重复。如果满足条件,我们就可以填写 $\textit{s}[j]$,并继续递归地填写下一个位置,即调用 $\textit{dfs}(i + 1)$。在递归调用结束后,我们需要将 $\textit{s}[j]$ 标记为未使用,以便于进行后面的枚举。
-在主函数中,我们首先对字符串进行排序,然后调用 $dfs(0)$,即从第 $0$ 个位置开始填写,最终返回答案数组即可。
+在主函数中,我们首先对字符串进行排序,然后调用 $\textit{dfs}(0)$,即从第 $0$ 个位置开始填写,最终返回答案数组即可。
时间复杂度 $O(n \times n!)$,空间复杂度 $O(n)$。其中 $n$ 是字符串 $s$ 的长度。需要进行 $n!$ 次枚举,每次枚举需要 $O(n)$ 的时间来判断是否重复。另外,我们需要一个标记数组来标记每个位置是否被使用过,因此空间复杂度为 $O(n)$。
@@ -56,21 +56,20 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/08.08.Permutation%20I
class Solution:
def permutation(self, S: str) -> List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
- for j in range(n):
- if vis[j] or (j and cs[j] == cs[j - 1] and not vis[j - 1]):
- continue
- t[i] = cs[j]
- vis[j] = True
- dfs(i + 1)
- vis[j] = False
-
- cs = sorted(S)
- n = len(cs)
+ for j, c in enumerate(s):
+ if not vis[j] and (j == 0 or s[j] != s[j - 1] or vis[j - 1]):
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
+
+ s = sorted(S)
ans = []
- t = [None] * n
+ t = s[:]
+ n = len(s)
vis = [False] * n
dfs(0)
return ans
@@ -80,35 +79,33 @@ class Solution:
```java
class Solution {
- private int n;
- private char[] cs;
- private List ans = new ArrayList<>();
+ private char[] s;
+ private char[] t;
private boolean[] vis;
- private StringBuilder t = new StringBuilder();
+ private List ans = new ArrayList<>();
public String[] permutation(String S) {
- cs = S.toCharArray();
- n = cs.length;
- Arrays.sort(cs);
+ int n = S.length();
+ s = S.toCharArray();
+ Arrays.sort(s);
+ t = new char[n];
vis = new boolean[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == n) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (int j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j] && (j == 0 || s[j] != s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.append(cs[j]);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[j] = false;
}
}
}
@@ -120,26 +117,23 @@ class Solution {
class Solution {
public:
vector permutation(string S) {
- vector cs(S.begin(), S.end());
- sort(cs.begin(), cs.end());
- int n = cs.size();
- vector ans;
+ ranges::sort(S);
+ string t = S;
+ int n = t.size();
vector vis(n);
- string t;
- function dfs = [&](int i) {
- if (i == n) {
- ans.push_back(t);
+ vector ans;
+ auto dfs = [&](this auto&& dfs, int i) {
+ if (i >= n) {
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j] || (j && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ if (!vis[j] && (j == 0 || S[j] != S[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(cs[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
@@ -152,26 +146,23 @@ public:
```go
func permutation(S string) (ans []string) {
- cs := []byte(S)
- sort.Slice(cs, func(i, j int) bool { return cs[i] < cs[j] })
- t := []byte{}
- n := len(cs)
- vis := make([]bool, n)
+ s := []byte(S)
+ sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
+ t := slices.Clone(s)
+ vis := make([]bool, len(s))
var dfs func(int)
dfs = func(i int) {
- if i == n {
+ if i >= len(s) {
ans = append(ans, string(t))
return
}
- for j := 0; j < n; j++ {
- if vis[j] || (j > 0 && !vis[j-1] && cs[j] == cs[j-1]) {
- continue
+ for j := range s {
+ if !vis[j] && (j == 0 || s[j] != s[j-1] || vis[j-1]) {
+ vis[j] = true
+ t[i] = s[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, cs[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
@@ -183,25 +174,23 @@ func permutation(S string) (ans []string) {
```ts
function permutation(S: string): string[] {
- const cs: string[] = S.split('').sort();
- const ans: string[] = [];
- const n = cs.length;
+ const s: string[] = S.split('').sort();
+ const n = s.length;
+ const t = Array(n).fill('');
const vis: boolean[] = Array(n).fill(false);
- const t: string[] = [];
+ const ans: string[] = [];
const dfs = (i: number) => {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
@@ -217,25 +206,23 @@ function permutation(S: string): string[] {
* @return {string[]}
*/
var permutation = function (S) {
- const cs = S.split('').sort();
- const ans = [];
- const n = cs.length;
+ const s = S.split('').sort();
+ const n = s.length;
+ const t = Array(n).fill('');
const vis = Array(n).fill(false);
- const t = [];
+ const ans = [];
const dfs = i => {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
@@ -247,36 +234,30 @@ var permutation = function (S) {
```swift
class Solution {
- private var n: Int = 0
- private var cs: [Character] = []
- private var ans: [String] = []
- private var vis: [Bool] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- cs = Array(S)
- n = cs.count
- cs.sort()
- vis = Array(repeating: false, count: n)
- dfs(0)
- return ans
- }
-
- private func dfs(_ i: Int) {
- if i == n {
- ans.append(t)
- return
- }
- for j in 0.. 0 && !vis[j - 1] && cs[j] == cs[j - 1]) {
- continue
+ var ans: [String] = []
+ var s: [Character] = Array(S).sorted()
+ var t: [Character] = Array(repeating: " ", count: s.count)
+ var vis: [Bool] = Array(repeating: false, count: s.count)
+ let n = s.count
+
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0..
@@ -64,21 +64,20 @@ The time complexity is $O(n \times n!)$, and the space complexity is $O(n)$. Her
class Solution:
def permutation(self, S: str) -> List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
- for j in range(n):
- if vis[j] or (j and cs[j] == cs[j - 1] and not vis[j - 1]):
- continue
- t[i] = cs[j]
- vis[j] = True
- dfs(i + 1)
- vis[j] = False
-
- cs = sorted(S)
- n = len(cs)
+ for j, c in enumerate(s):
+ if not vis[j] and (j == 0 or s[j] != s[j - 1] or vis[j - 1]):
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
+
+ s = sorted(S)
ans = []
- t = [None] * n
+ t = s[:]
+ n = len(s)
vis = [False] * n
dfs(0)
return ans
@@ -88,35 +87,33 @@ class Solution:
```java
class Solution {
- private int n;
- private char[] cs;
- private List ans = new ArrayList<>();
+ private char[] s;
+ private char[] t;
private boolean[] vis;
- private StringBuilder t = new StringBuilder();
+ private List ans = new ArrayList<>();
public String[] permutation(String S) {
- cs = S.toCharArray();
- n = cs.length;
- Arrays.sort(cs);
+ int n = S.length();
+ s = S.toCharArray();
+ Arrays.sort(s);
+ t = new char[n];
vis = new boolean[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == n) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (int j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j] && (j == 0 || s[j] != s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.append(cs[j]);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[j] = false;
}
}
}
@@ -128,26 +125,23 @@ class Solution {
class Solution {
public:
vector permutation(string S) {
- vector cs(S.begin(), S.end());
- sort(cs.begin(), cs.end());
- int n = cs.size();
- vector ans;
+ ranges::sort(S);
+ string t = S;
+ int n = t.size();
vector vis(n);
- string t;
- function dfs = [&](int i) {
- if (i == n) {
- ans.push_back(t);
+ vector ans;
+ auto dfs = [&](this auto&& dfs, int i) {
+ if (i >= n) {
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j] || (j && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ if (!vis[j] && (j == 0 || S[j] != S[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(cs[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
@@ -160,26 +154,23 @@ public:
```go
func permutation(S string) (ans []string) {
- cs := []byte(S)
- sort.Slice(cs, func(i, j int) bool { return cs[i] < cs[j] })
- t := []byte{}
- n := len(cs)
- vis := make([]bool, n)
+ s := []byte(S)
+ sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
+ t := slices.Clone(s)
+ vis := make([]bool, len(s))
var dfs func(int)
dfs = func(i int) {
- if i == n {
+ if i >= len(s) {
ans = append(ans, string(t))
return
}
- for j := 0; j < n; j++ {
- if vis[j] || (j > 0 && !vis[j-1] && cs[j] == cs[j-1]) {
- continue
+ for j := range s {
+ if !vis[j] && (j == 0 || s[j] != s[j-1] || vis[j-1]) {
+ vis[j] = true
+ t[i] = s[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, cs[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
@@ -191,25 +182,23 @@ func permutation(S string) (ans []string) {
```ts
function permutation(S: string): string[] {
- const cs: string[] = S.split('').sort();
- const ans: string[] = [];
- const n = cs.length;
+ const s: string[] = S.split('').sort();
+ const n = s.length;
+ const t = Array(n).fill('');
const vis: boolean[] = Array(n).fill(false);
- const t: string[] = [];
+ const ans: string[] = [];
const dfs = (i: number) => {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
@@ -225,25 +214,23 @@ function permutation(S: string): string[] {
* @return {string[]}
*/
var permutation = function (S) {
- const cs = S.split('').sort();
- const ans = [];
- const n = cs.length;
+ const s = S.split('').sort();
+ const n = s.length;
+ const t = Array(n).fill('');
const vis = Array(n).fill(false);
- const t = [];
+ const ans = [];
const dfs = i => {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
@@ -255,36 +242,30 @@ var permutation = function (S) {
```swift
class Solution {
- private var n: Int = 0
- private var cs: [Character] = []
- private var ans: [String] = []
- private var vis: [Bool] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- cs = Array(S)
- n = cs.count
- cs.sort()
- vis = Array(repeating: false, count: n)
- dfs(0)
- return ans
- }
-
- private func dfs(_ i: Int) {
- if i == n {
- ans.append(t)
- return
- }
- for j in 0.. 0 && !vis[j - 1] && cs[j] == cs[j - 1]) {
- continue
+ var ans: [String] = []
+ var s: [Character] = Array(S).sorted()
+ var t: [Character] = Array(repeating: " ", count: s.count)
+ var vis: [Bool] = Array(repeating: false, count: s.count)
+ let n = s.count
+
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0.. permutation(string S) {
- vector cs(S.begin(), S.end());
- sort(cs.begin(), cs.end());
- int n = cs.size();
- vector ans;
+ ranges::sort(S);
+ string t = S;
+ int n = t.size();
vector vis(n);
- string t;
- function dfs = [&](int i) {
- if (i == n) {
- ans.push_back(t);
+ vector ans;
+ auto dfs = [&](this auto&& dfs, int i) {
+ if (i >= n) {
+ ans.emplace_back(t);
return;
}
for (int j = 0; j < n; ++j) {
- if (vis[j] || (j && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ if (!vis[j] && (j == 0 || S[j] != S[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = S[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push_back(cs[j]);
- dfs(i + 1);
- t.pop_back();
- vis[j] = false;
}
};
dfs(0);
return ans;
}
-};
\ No newline at end of file
+};
diff --git a/lcci/08.08.Permutation II/Solution.go b/lcci/08.08.Permutation II/Solution.go
index bdb449b7c9389..ce2be679b7676 100644
--- a/lcci/08.08.Permutation II/Solution.go
+++ b/lcci/08.08.Permutation II/Solution.go
@@ -1,26 +1,23 @@
func permutation(S string) (ans []string) {
- cs := []byte(S)
- sort.Slice(cs, func(i, j int) bool { return cs[i] < cs[j] })
- t := []byte{}
- n := len(cs)
- vis := make([]bool, n)
+ s := []byte(S)
+ sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
+ t := slices.Clone(s)
+ vis := make([]bool, len(s))
var dfs func(int)
dfs = func(i int) {
- if i == n {
+ if i >= len(s) {
ans = append(ans, string(t))
return
}
- for j := 0; j < n; j++ {
- if vis[j] || (j > 0 && !vis[j-1] && cs[j] == cs[j-1]) {
- continue
+ for j := range s {
+ if !vis[j] && (j == 0 || s[j] != s[j-1] || vis[j-1]) {
+ vis[j] = true
+ t[i] = s[j]
+ dfs(i + 1)
+ vis[j] = false
}
- vis[j] = true
- t = append(t, cs[j])
- dfs(i + 1)
- t = t[:len(t)-1]
- vis[j] = false
}
}
dfs(0)
return
-}
\ No newline at end of file
+}
diff --git a/lcci/08.08.Permutation II/Solution.java b/lcci/08.08.Permutation II/Solution.java
index e0dffd2d0cfae..b03452a42cd0d 100644
--- a/lcci/08.08.Permutation II/Solution.java
+++ b/lcci/08.08.Permutation II/Solution.java
@@ -1,33 +1,31 @@
class Solution {
- private int n;
- private char[] cs;
- private List ans = new ArrayList<>();
+ private char[] s;
+ private char[] t;
private boolean[] vis;
- private StringBuilder t = new StringBuilder();
+ private List ans = new ArrayList<>();
public String[] permutation(String S) {
- cs = S.toCharArray();
- n = cs.length;
- Arrays.sort(cs);
+ int n = S.length();
+ s = S.toCharArray();
+ Arrays.sort(s);
+ t = new char[n];
vis = new boolean[n];
dfs(0);
return ans.toArray(new String[0]);
}
private void dfs(int i) {
- if (i == n) {
- ans.add(t.toString());
+ if (i >= s.length) {
+ ans.add(new String(t));
return;
}
- for (int j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] == cs[j - 1])) {
- continue;
+ for (int j = 0; j < s.length; ++j) {
+ if (!vis[j] && (j == 0 || s[j] != s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.append(cs[j]);
- dfs(i + 1);
- t.deleteCharAt(t.length() - 1);
- vis[j] = false;
}
}
-}
\ No newline at end of file
+}
diff --git a/lcci/08.08.Permutation II/Solution.js b/lcci/08.08.Permutation II/Solution.js
index 44aed97be109c..4bb6b59170d9f 100644
--- a/lcci/08.08.Permutation II/Solution.js
+++ b/lcci/08.08.Permutation II/Solution.js
@@ -3,25 +3,23 @@
* @return {string[]}
*/
var permutation = function (S) {
- const cs = S.split('').sort();
- const ans = [];
- const n = cs.length;
+ const s = S.split('').sort();
+ const n = s.length;
+ const t = Array(n).fill('');
const vis = Array(n).fill(false);
- const t = [];
+ const ans = [];
const dfs = i => {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
diff --git a/lcci/08.08.Permutation II/Solution.py b/lcci/08.08.Permutation II/Solution.py
index e6b19ccba395a..e39d27633f10d 100644
--- a/lcci/08.08.Permutation II/Solution.py
+++ b/lcci/08.08.Permutation II/Solution.py
@@ -1,21 +1,20 @@
class Solution:
def permutation(self, S: str) -> List[str]:
def dfs(i: int):
- if i == n:
+ if i >= n:
ans.append("".join(t))
return
- for j in range(n):
- if vis[j] or (j and cs[j] == cs[j - 1] and not vis[j - 1]):
- continue
- t[i] = cs[j]
- vis[j] = True
- dfs(i + 1)
- vis[j] = False
+ for j, c in enumerate(s):
+ if not vis[j] and (j == 0 or s[j] != s[j - 1] or vis[j - 1]):
+ vis[j] = True
+ t[i] = c
+ dfs(i + 1)
+ vis[j] = False
- cs = sorted(S)
- n = len(cs)
+ s = sorted(S)
ans = []
- t = [None] * n
+ t = s[:]
+ n = len(s)
vis = [False] * n
dfs(0)
return ans
diff --git a/lcci/08.08.Permutation II/Solution.swift b/lcci/08.08.Permutation II/Solution.swift
index a00ac743ff082..84151d360dc86 100644
--- a/lcci/08.08.Permutation II/Solution.swift
+++ b/lcci/08.08.Permutation II/Solution.swift
@@ -1,33 +1,27 @@
class Solution {
- private var n: Int = 0
- private var cs: [Character] = []
- private var ans: [String] = []
- private var vis: [Bool] = []
- private var t: String = ""
-
func permutation(_ S: String) -> [String] {
- cs = Array(S)
- n = cs.count
- cs.sort()
- vis = Array(repeating: false, count: n)
- dfs(0)
- return ans
- }
+ var ans: [String] = []
+ var s: [Character] = Array(S).sorted()
+ var t: [Character] = Array(repeating: " ", count: s.count)
+ var vis: [Bool] = Array(repeating: false, count: s.count)
+ let n = s.count
- private func dfs(_ i: Int) {
- if i == n {
- ans.append(t)
- return
- }
- for j in 0.. 0 && !vis[j - 1] && cs[j] == cs[j - 1]) {
- continue
+ func dfs(_ i: Int) {
+ if i >= n {
+ ans.append(String(t))
+ return
+ }
+ for j in 0.. {
- if (i === n) {
+ if (i >= n) {
ans.push(t.join(''));
return;
}
for (let j = 0; j < n; ++j) {
- if (vis[j] || (j > 0 && !vis[j - 1] && cs[j] === cs[j - 1])) {
- continue;
+ if (!vis[j] && (j === 0 || s[j] !== s[j - 1] || vis[j - 1])) {
+ vis[j] = true;
+ t[i] = s[j];
+ dfs(i + 1);
+ vis[j] = false;
}
- vis[j] = true;
- t.push(cs[j]);
- dfs(i + 1);
- t.pop();
- vis[j] = false;
}
};
dfs(0);
diff --git a/lcci/08.09.Bracket/README.md b/lcci/08.09.Bracket/README.md
index 6e4a46e5769b9..7272118acce4c 100644
--- a/lcci/08.09.Bracket/README.md
+++ b/lcci/08.09.Bracket/README.md
@@ -104,8 +104,7 @@ class Solution {
public:
vector generateParenthesis(int n) {
vector ans;
- function dfs;
- dfs = [&](int l, int r, string t) {
+ auto dfs = [&](this auto&& dfs, int l, int r, string t) {
if (l > n || r > n || l < r) return;
if (l == n && r == n) {
ans.push_back(t);
diff --git a/lcci/08.09.Bracket/README_EN.md b/lcci/08.09.Bracket/README_EN.md
index 295bd24efe68f..36ee966e887ab 100644
--- a/lcci/08.09.Bracket/README_EN.md
+++ b/lcci/08.09.Bracket/README_EN.md
@@ -112,8 +112,7 @@ class Solution {
public:
vector generateParenthesis(int n) {
vector ans;
- function dfs;
- dfs = [&](int l, int r, string t) {
+ auto dfs = [&](this auto&& dfs, int l, int r, string t) {
if (l > n || r > n || l < r) return;
if (l == n && r == n) {
ans.push_back(t);
diff --git a/lcci/08.09.Bracket/Solution.cpp b/lcci/08.09.Bracket/Solution.cpp
index 4c9a371b251c4..d386301341d2c 100644
--- a/lcci/08.09.Bracket/Solution.cpp
+++ b/lcci/08.09.Bracket/Solution.cpp
@@ -2,8 +2,7 @@ class Solution {
public:
vector generateParenthesis(int n) {
vector ans;
- function dfs;
- dfs = [&](int l, int r, string t) {
+ auto dfs = [&](this auto&& dfs, int l, int r, string t) {
if (l > n || r > n || l < r) return;
if (l == n && r == n) {
ans.push_back(t);
@@ -15,4 +14,4 @@ class Solution {
dfs(0, 0, "");
return ans;
}
-};
\ No newline at end of file
+};
diff --git a/lcci/17.15.Longest Word/README.md b/lcci/17.15.Longest Word/README.md
index a9840705c9c6a..0f6dffe5c3aa8 100644
--- a/lcci/17.15.Longest Word/README.md
+++ b/lcci/17.15.Longest Word/README.md
@@ -32,117 +32,79 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/17.15.Longest%20Word/
-### 方法一:前缀树 + DFS
+### 方法一:哈希表 + 排序 + DFS
+
+注意,题目中,每个单词实际上允许重复使用。
+
+我们可以用一个哈希表 $\textit{s}$ 存储所有单词,然后对单词按照长度降序排序,如果长度相同,按照字典序升序排序。
+
+接下来,我们遍历排序后的单词列表,对于每个单词 $\textit{w}$,我们先将其从哈希表 $\textit{s}$ 中移除,然后使用深度优先搜索 $\textit{dfs}$ 判断 $\textit{w}$ 是否可以由其他单词组成,如果可以,返回 $\textit{w}$。
+
+函数 $\textit{dfs}$ 的执行逻辑如下:
+
+- 如果 $\textit{w}$ 为空,返回 $\text{true}$;
+- 遍历 $\textit{w}$ 的所有前缀,如果前缀在哈希表 $\textit{s}$ 中且 $\textit{dfs}$ 返回 $\text{true}$,则返回 $\text{true}$;
+- 如果没有符合条件的前缀,返回 $\text{false}$。
+
+如果没有找到符合条件的单词,返回空字符串。
+
+时间复杂度 $O(m \times n \times \log n + n \times 2^M)$,空间复杂度 $O(m \times n)$。其中 $n$ 和 $m$ 分别为单词列表的长度和单词的平均长度,而 $M$ 为最长单词的长度。
#### Python3
```python
-class Trie:
- def __init__(self):
- self.children = [None] * 26
- self.is_end = False
-
- def insert(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- node.children[idx] = Trie()
- node = node.children[idx]
- node.is_end = True
-
- def search(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- return False
- node = node.children[idx]
- return node.is_end
-
-
class Solution:
def longestWord(self, words: List[str]) -> str:
- def cmp(a, b):
- if len(a) != len(b):
- return len(a) - len(b)
- return -1 if a > b else 1
-
- def dfs(w):
- return not w or any(
- trie.search(w[:i]) and dfs(w[i:]) for i in range(1, len(w) + 1)
- )
-
- words.sort(key=cmp_to_key(cmp))
- trie = Trie()
- ans = ""
+ def dfs(w: str) -> bool:
+ if not w:
+ return True
+ for k in range(1, len(w) + 1):
+ if w[:k] in s and dfs(w[k:]):
+ return True
+ return False
+
+ s = set(words)
+ words.sort(key=lambda x: (-len(x), x))
for w in words:
+ s.remove(w)
if dfs(w):
- ans = w
- trie.insert(w)
- return ans
+ return w
+ return ""
```
#### Java
```java
-class Trie {
- Trie[] children = new Trie[26];
- boolean isEnd;
-
- void insert(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- node.children[c] = new Trie();
- }
- node = node.children[c];
- }
- node.isEnd = true;
- }
-
- boolean search(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- return false;
- }
- node = node.children[c];
- }
- return node.isEnd;
- }
-}
-
class Solution {
- private Trie trie = new Trie();
+ private Set s = new HashSet<>();
public String longestWord(String[] words) {
+ for (String w : words) {
+ s.add(w);
+ }
Arrays.sort(words, (a, b) -> {
if (a.length() != b.length()) {
- return a.length() - b.length();
+ return b.length() - a.length();
}
- return b.compareTo(a);
+ return a.compareTo(b);
});
- String ans = "";
for (String w : words) {
+ s.remove(w);
if (dfs(w)) {
- ans = w;
+ return w;
}
- trie.insert(w);
}
- return ans;
+ return "";
}
private boolean dfs(String w) {
- if ("".equals(w)) {
+ if (w.length() == 0) {
return true;
}
- for (int i = 1; i <= w.length(); ++i) {
- if (trie.search(w.substring(0, i)) && dfs(w.substring(i))) {
+ for (int k = 1; k <= w.length(); ++k) {
+ if (s.contains(w.substring(0, k)) && dfs(w.substring(k))) {
return true;
}
}
@@ -151,131 +113,171 @@ class Solution {
}
```
-#### Go
-
-```go
-type Trie struct {
- children [26]*Trie
- isEnd bool
-}
+#### C++
-func newTrie() *Trie {
- return &Trie{}
-}
-func (this *Trie) insert(word string) {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- node.children[c] = newTrie()
- }
- node = node.children[c]
- }
- node.isEnd = true
-}
+```cpp
+class Solution {
+public:
+ string longestWord(vector& words) {
+ unordered_set s(words.begin(), words.end());
+ ranges::sort(words, [&](const string& a, const string& b) {
+ return a.size() > b.size() || (a.size() == b.size() && a < b);
+ });
+ auto dfs = [&](this auto&& dfs, string w) -> bool {
+ if (w.empty()) {
+ return true;
+ }
+ for (int k = 1; k <= w.size(); ++k) {
+ if (s.contains(w.substr(0, k)) && dfs(w.substr(k))) {
+ return true;
+ }
+ }
+ return false;
+ };
+ for (const string& w : words) {
+ s.erase(w);
+ if (dfs(w)) {
+ return w;
+ }
+ }
+ return "";
+ }
+};
+```
-func (this *Trie) search(word string) bool {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- return false
- }
- node = node.children[c]
- }
- return node.isEnd
-}
+#### Go
+```go
func longestWord(words []string) string {
+ s := map[string]bool{}
+ for _, w := range words {
+ s[w] = true
+ }
sort.Slice(words, func(i, j int) bool {
- a, b := words[i], words[j]
- if len(a) != len(b) {
- return len(a) < len(b)
- }
- return a > b
+ return len(words[i]) > len(words[j]) || (len(words[i]) == len(words[j]) && words[i] < words[j])
})
- trie := newTrie()
var dfs func(string) bool
dfs = func(w string) bool {
if len(w) == 0 {
return true
}
- for i := 1; i <= len(w); i++ {
- if trie.search(w[:i]) && dfs(w[i:]) {
+ for k := 1; k <= len(w); k++ {
+ if s[w[:k]] && dfs(w[k:]) {
return true
}
}
return false
}
- ans := ""
for _, w := range words {
+ s[w] = false
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
+ return ""
}
```
-#### Swift
+#### TypeScript
-```swift
-class Trie {
- var children = [Trie?](repeating: nil, count: 26)
- var isEnd = false
-
- func insert(_ word: String) {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- node.children[index] = Trie()
+```ts
+function longestWord(words: string[]): string {
+ const s = new Set(words);
+
+ words.sort((a, b) => (a.length === b.length ? a.localeCompare(b) : b.length - a.length));
+
+ const dfs = (w: string): boolean => {
+ if (w === '') {
+ return true;
+ }
+ for (let k = 1; k <= w.length; ++k) {
+ if (s.has(w.substring(0, k)) && dfs(w.substring(k))) {
+ return true;
}
- node = node.children[index]!
}
- node.isEnd = true
+ return false;
+ };
+
+ for (const w of words) {
+ s.delete(w);
+ if (dfs(w)) {
+ return w;
+ }
}
- func search(_ word: String) -> Bool {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- return false
+ return '';
+}
+```
+
+#### Rust
+
+```rust
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn longest_word(words: Vec) -> String {
+ let mut s: HashSet = words.iter().cloned().collect();
+ let mut words = words;
+ words.sort_by(|a, b| b.len().cmp(&a.len()).then(a.cmp(b)));
+
+ fn dfs(w: String, s: &mut HashSet) -> bool {
+ if w.is_empty() {
+ return true;
}
- node = node.children[index]!
+ for k in 1..=w.len() {
+ if s.contains(&w[0..k]) && dfs(w[k..].to_string(), s) {
+ return true;
+ }
+ }
+ false
}
- return node.isEnd
+ for w in words {
+ s.remove(&w);
+ if dfs(w.clone(), &mut s) {
+ return w;
+ }
+ }
+ String::new()
}
}
+```
+
+#### Swift
+```swift
class Solution {
func longestWord(_ words: [String]) -> String {
- var words = words.sorted(by: { $0.count < $1.count || ($0.count == $1.count && $0 > $1) })
- let trie = Trie()
+ var s: Set = Set(words)
+ var words = words
+ words.sort { (a, b) -> Bool in
+ if a.count == b.count {
+ return a < b
+ } else {
+ return a.count > b.count
+ }
+ }
- var dfs: ((String) -> Bool)!
- dfs = { w in
+ func dfs(_ w: String) -> Bool {
if w.isEmpty {
return true
}
- for i in 1...w.count {
- if trie.search(String(w.prefix(i))) && dfs(String(w.suffix(w.count - i))) {
+ for k in 1...w.count {
+ let prefix = String(w.prefix(k))
+ if s.contains(prefix) && dfs(String(w.dropFirst(k))) {
return true
}
}
return false
}
- var ans = ""
for w in words {
+ s.remove(w)
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
+
+ return ""
}
}
```
diff --git a/lcci/17.15.Longest Word/README_EN.md b/lcci/17.15.Longest Word/README_EN.md
index 7d5dcf7f14dec..131326adf233f 100644
--- a/lcci/17.15.Longest Word/README_EN.md
+++ b/lcci/17.15.Longest Word/README_EN.md
@@ -41,117 +41,79 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/17.15.Longest%20Word/
-### Solution 1
+### Solution 1: Hash Table + Sorting + DFS
+
+Note that in the problem, each word can actually be reused.
+
+We can use a hash table $\textit{s}$ to store all the words, then sort the words in descending order of length, and if the lengths are the same, sort them in ascending lexicographical order.
+
+Next, we iterate through the sorted list of words. For each word $\textit{w}$, we first remove it from the hash table $\textit{s}$, then use depth-first search $\textit{dfs}$ to determine if $\textit{w}$ can be composed of other words. If it can, we return $\textit{w}$.
+
+The execution logic of the function $\textit{dfs}$ is as follows:
+
+- If $\textit{w}$ is empty, return $\text{true}$;
+- Iterate through all prefixes of $\textit{w}$. If a prefix is in the hash table $\textit{s}$ and $\textit{dfs}$ returns $\text{true}$, then return $\text{true}$;
+- If no prefix meets the condition, return $\text{false}$.
+
+If no word meets the condition, return an empty string.
+
+The time complexity is $O(m \times n \times \log n + n \times 2^M)$, and the space complexity is $O(m \times n)$. Here, $n$ and $m$ are the length of the word list and the average length of the words, respectively, and $M$ is the length of the longest word.
#### Python3
```python
-class Trie:
- def __init__(self):
- self.children = [None] * 26
- self.is_end = False
-
- def insert(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- node.children[idx] = Trie()
- node = node.children[idx]
- node.is_end = True
-
- def search(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- return False
- node = node.children[idx]
- return node.is_end
-
-
class Solution:
def longestWord(self, words: List[str]) -> str:
- def cmp(a, b):
- if len(a) != len(b):
- return len(a) - len(b)
- return -1 if a > b else 1
-
- def dfs(w):
- return not w or any(
- trie.search(w[:i]) and dfs(w[i:]) for i in range(1, len(w) + 1)
- )
-
- words.sort(key=cmp_to_key(cmp))
- trie = Trie()
- ans = ""
+ def dfs(w: str) -> bool:
+ if not w:
+ return True
+ for k in range(1, len(w) + 1):
+ if w[:k] in s and dfs(w[k:]):
+ return True
+ return False
+
+ s = set(words)
+ words.sort(key=lambda x: (-len(x), x))
for w in words:
+ s.remove(w)
if dfs(w):
- ans = w
- trie.insert(w)
- return ans
+ return w
+ return ""
```
#### Java
```java
-class Trie {
- Trie[] children = new Trie[26];
- boolean isEnd;
-
- void insert(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- node.children[c] = new Trie();
- }
- node = node.children[c];
- }
- node.isEnd = true;
- }
-
- boolean search(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- return false;
- }
- node = node.children[c];
- }
- return node.isEnd;
- }
-}
-
class Solution {
- private Trie trie = new Trie();
+ private Set s = new HashSet<>();
public String longestWord(String[] words) {
+ for (String w : words) {
+ s.add(w);
+ }
Arrays.sort(words, (a, b) -> {
if (a.length() != b.length()) {
- return a.length() - b.length();
+ return b.length() - a.length();
}
- return b.compareTo(a);
+ return a.compareTo(b);
});
- String ans = "";
for (String w : words) {
+ s.remove(w);
if (dfs(w)) {
- ans = w;
+ return w;
}
- trie.insert(w);
}
- return ans;
+ return "";
}
private boolean dfs(String w) {
- if ("".equals(w)) {
+ if (w.length() == 0) {
return true;
}
- for (int i = 1; i <= w.length(); ++i) {
- if (trie.search(w.substring(0, i)) && dfs(w.substring(i))) {
+ for (int k = 1; k <= w.length(); ++k) {
+ if (s.contains(w.substring(0, k)) && dfs(w.substring(k))) {
return true;
}
}
@@ -160,131 +122,171 @@ class Solution {
}
```
-#### Go
-
-```go
-type Trie struct {
- children [26]*Trie
- isEnd bool
-}
+#### C++
-func newTrie() *Trie {
- return &Trie{}
-}
-func (this *Trie) insert(word string) {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- node.children[c] = newTrie()
- }
- node = node.children[c]
- }
- node.isEnd = true
-}
+```cpp
+class Solution {
+public:
+ string longestWord(vector& words) {
+ unordered_set s(words.begin(), words.end());
+ ranges::sort(words, [&](const string& a, const string& b) {
+ return a.size() > b.size() || (a.size() == b.size() && a < b);
+ });
+ auto dfs = [&](this auto&& dfs, string w) -> bool {
+ if (w.empty()) {
+ return true;
+ }
+ for (int k = 1; k <= w.size(); ++k) {
+ if (s.contains(w.substr(0, k)) && dfs(w.substr(k))) {
+ return true;
+ }
+ }
+ return false;
+ };
+ for (const string& w : words) {
+ s.erase(w);
+ if (dfs(w)) {
+ return w;
+ }
+ }
+ return "";
+ }
+};
+```
-func (this *Trie) search(word string) bool {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- return false
- }
- node = node.children[c]
- }
- return node.isEnd
-}
+#### Go
+```go
func longestWord(words []string) string {
+ s := map[string]bool{}
+ for _, w := range words {
+ s[w] = true
+ }
sort.Slice(words, func(i, j int) bool {
- a, b := words[i], words[j]
- if len(a) != len(b) {
- return len(a) < len(b)
- }
- return a > b
+ return len(words[i]) > len(words[j]) || (len(words[i]) == len(words[j]) && words[i] < words[j])
})
- trie := newTrie()
var dfs func(string) bool
dfs = func(w string) bool {
if len(w) == 0 {
return true
}
- for i := 1; i <= len(w); i++ {
- if trie.search(w[:i]) && dfs(w[i:]) {
+ for k := 1; k <= len(w); k++ {
+ if s[w[:k]] && dfs(w[k:]) {
return true
}
}
return false
}
- ans := ""
for _, w := range words {
+ s[w] = false
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
+ return ""
}
```
-#### Swift
+#### TypeScript
-```swift
-class Trie {
- var children = [Trie?](repeating: nil, count: 26)
- var isEnd = false
-
- func insert(_ word: String) {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- node.children[index] = Trie()
+```ts
+function longestWord(words: string[]): string {
+ const s = new Set(words);
+
+ words.sort((a, b) => (a.length === b.length ? a.localeCompare(b) : b.length - a.length));
+
+ const dfs = (w: string): boolean => {
+ if (w === '') {
+ return true;
+ }
+ for (let k = 1; k <= w.length; ++k) {
+ if (s.has(w.substring(0, k)) && dfs(w.substring(k))) {
+ return true;
}
- node = node.children[index]!
}
- node.isEnd = true
+ return false;
+ };
+
+ for (const w of words) {
+ s.delete(w);
+ if (dfs(w)) {
+ return w;
+ }
}
- func search(_ word: String) -> Bool {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- return false
+ return '';
+}
+```
+
+#### Rust
+
+```rust
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn longest_word(words: Vec) -> String {
+ let mut s: HashSet = words.iter().cloned().collect();
+ let mut words = words;
+ words.sort_by(|a, b| b.len().cmp(&a.len()).then(a.cmp(b)));
+
+ fn dfs(w: String, s: &mut HashSet) -> bool {
+ if w.is_empty() {
+ return true;
}
- node = node.children[index]!
+ for k in 1..=w.len() {
+ if s.contains(&w[0..k]) && dfs(w[k..].to_string(), s) {
+ return true;
+ }
+ }
+ false
}
- return node.isEnd
+ for w in words {
+ s.remove(&w);
+ if dfs(w.clone(), &mut s) {
+ return w;
+ }
+ }
+ String::new()
}
}
+```
+
+#### Swift
+```swift
class Solution {
func longestWord(_ words: [String]) -> String {
- var words = words.sorted(by: { $0.count < $1.count || ($0.count == $1.count && $0 > $1) })
- let trie = Trie()
+ var s: Set = Set(words)
+ var words = words
+ words.sort { (a, b) -> Bool in
+ if a.count == b.count {
+ return a < b
+ } else {
+ return a.count > b.count
+ }
+ }
- var dfs: ((String) -> Bool)!
- dfs = { w in
+ func dfs(_ w: String) -> Bool {
if w.isEmpty {
return true
}
- for i in 1...w.count {
- if trie.search(String(w.prefix(i))) && dfs(String(w.suffix(w.count - i))) {
+ for k in 1...w.count {
+ let prefix = String(w.prefix(k))
+ if s.contains(prefix) && dfs(String(w.dropFirst(k))) {
return true
}
}
return false
}
- var ans = ""
for w in words {
+ s.remove(w)
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
+
+ return ""
}
}
```
diff --git a/lcci/17.15.Longest Word/Solution.cpp b/lcci/17.15.Longest Word/Solution.cpp
new file mode 100644
index 0000000000000..19b158b023c7d
--- /dev/null
+++ b/lcci/17.15.Longest Word/Solution.cpp
@@ -0,0 +1,27 @@
+class Solution {
+public:
+ string longestWord(vector& words) {
+ unordered_set s(words.begin(), words.end());
+ ranges::sort(words, [&](const string& a, const string& b) {
+ return a.size() > b.size() || (a.size() == b.size() && a < b);
+ });
+ auto dfs = [&](this auto&& dfs, string w) -> bool {
+ if (w.empty()) {
+ return true;
+ }
+ for (int k = 1; k <= w.size(); ++k) {
+ if (s.contains(w.substr(0, k)) && dfs(w.substr(k))) {
+ return true;
+ }
+ }
+ return false;
+ };
+ for (const string& w : words) {
+ s.erase(w);
+ if (dfs(w)) {
+ return w;
+ }
+ }
+ return "";
+ }
+};
diff --git a/lcci/17.15.Longest Word/Solution.go b/lcci/17.15.Longest Word/Solution.go
index 2a6dbd07cf5a4..321fb05d318ae 100644
--- a/lcci/17.15.Longest Word/Solution.go
+++ b/lcci/17.15.Longest Word/Solution.go
@@ -1,62 +1,28 @@
-type Trie struct {
- children [26]*Trie
- isEnd bool
-}
-
-func newTrie() *Trie {
- return &Trie{}
-}
-func (this *Trie) insert(word string) {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- node.children[c] = newTrie()
- }
- node = node.children[c]
- }
- node.isEnd = true
-}
-
-func (this *Trie) search(word string) bool {
- node := this
- for _, c := range word {
- c -= 'a'
- if node.children[c] == nil {
- return false
- }
- node = node.children[c]
- }
- return node.isEnd
-}
-
func longestWord(words []string) string {
+ s := map[string]bool{}
+ for _, w := range words {
+ s[w] = true
+ }
sort.Slice(words, func(i, j int) bool {
- a, b := words[i], words[j]
- if len(a) != len(b) {
- return len(a) < len(b)
- }
- return a > b
+ return len(words[i]) > len(words[j]) || (len(words[i]) == len(words[j]) && words[i] < words[j])
})
- trie := newTrie()
var dfs func(string) bool
dfs = func(w string) bool {
if len(w) == 0 {
return true
}
- for i := 1; i <= len(w); i++ {
- if trie.search(w[:i]) && dfs(w[i:]) {
+ for k := 1; k <= len(w); k++ {
+ if s[w[:k]] && dfs(w[k:]) {
return true
}
}
return false
}
- ans := ""
for _, w := range words {
+ s[w] = false
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
-}
\ No newline at end of file
+ return ""
+}
diff --git a/lcci/17.15.Longest Word/Solution.java b/lcci/17.15.Longest Word/Solution.java
index 2d6e2d40bd4c3..e7bbcc380a592 100644
--- a/lcci/17.15.Longest Word/Solution.java
+++ b/lcci/17.15.Longest Word/Solution.java
@@ -1,61 +1,34 @@
-class Trie {
- Trie[] children = new Trie[26];
- boolean isEnd;
-
- void insert(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- node.children[c] = new Trie();
- }
- node = node.children[c];
- }
- node.isEnd = true;
- }
-
- boolean search(String word) {
- Trie node = this;
- for (char c : word.toCharArray()) {
- c -= 'a';
- if (node.children[c] == null) {
- return false;
- }
- node = node.children[c];
- }
- return node.isEnd;
- }
-}
-
class Solution {
- private Trie trie = new Trie();
+ private Set s = new HashSet<>();
public String longestWord(String[] words) {
+ for (String w : words) {
+ s.add(w);
+ }
Arrays.sort(words, (a, b) -> {
if (a.length() != b.length()) {
- return a.length() - b.length();
+ return b.length() - a.length();
}
- return b.compareTo(a);
+ return a.compareTo(b);
});
- String ans = "";
for (String w : words) {
+ s.remove(w);
if (dfs(w)) {
- ans = w;
+ return w;
}
- trie.insert(w);
}
- return ans;
+ return "";
}
private boolean dfs(String w) {
- if ("".equals(w)) {
+ if (w.length() == 0) {
return true;
}
- for (int i = 1; i <= w.length(); ++i) {
- if (trie.search(w.substring(0, i)) && dfs(w.substring(i))) {
+ for (int k = 1; k <= w.length(); ++k) {
+ if (s.contains(w.substring(0, k)) && dfs(w.substring(k))) {
return true;
}
}
return false;
}
-}
\ No newline at end of file
+}
diff --git a/lcci/17.15.Longest Word/Solution.py b/lcci/17.15.Longest Word/Solution.py
index 5a5b69545a1a2..c2dd7b8387c09 100644
--- a/lcci/17.15.Longest Word/Solution.py
+++ b/lcci/17.15.Longest Word/Solution.py
@@ -1,44 +1,17 @@
-class Trie:
- def __init__(self):
- self.children = [None] * 26
- self.is_end = False
-
- def insert(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- node.children[idx] = Trie()
- node = node.children[idx]
- node.is_end = True
-
- def search(self, word):
- node = self
- for c in word:
- idx = ord(c) - ord('a')
- if node.children[idx] is None:
- return False
- node = node.children[idx]
- return node.is_end
-
-
class Solution:
def longestWord(self, words: List[str]) -> str:
- def cmp(a, b):
- if len(a) != len(b):
- return len(a) - len(b)
- return -1 if a > b else 1
-
- def dfs(w):
- return not w or any(
- trie.search(w[:i]) and dfs(w[i:]) for i in range(1, len(w) + 1)
- )
+ def dfs(w: str) -> bool:
+ if not w:
+ return True
+ for k in range(1, len(w) + 1):
+ if w[:k] in s and dfs(w[k:]):
+ return True
+ return False
- words.sort(key=cmp_to_key(cmp))
- trie = Trie()
- ans = ""
+ s = set(words)
+ words.sort(key=lambda x: (-len(x), x))
for w in words:
+ s.remove(w)
if dfs(w):
- ans = w
- trie.insert(w)
- return ans
+ return w
+ return ""
diff --git a/lcci/17.15.Longest Word/Solution.rs b/lcci/17.15.Longest Word/Solution.rs
new file mode 100644
index 0000000000000..068124b25c26a
--- /dev/null
+++ b/lcci/17.15.Longest Word/Solution.rs
@@ -0,0 +1,28 @@
+use std::collections::HashSet;
+
+impl Solution {
+ pub fn longest_word(words: Vec) -> String {
+ let mut s: HashSet = words.iter().cloned().collect();
+ let mut words = words;
+ words.sort_by(|a, b| b.len().cmp(&a.len()).then(a.cmp(b)));
+
+ fn dfs(w: String, s: &mut HashSet) -> bool {
+ if w.is_empty() {
+ return true;
+ }
+ for k in 1..=w.len() {
+ if s.contains(&w[0..k]) && dfs(w[k..].to_string(), s) {
+ return true;
+ }
+ }
+ false
+ }
+ for w in words {
+ s.remove(&w);
+ if dfs(w.clone(), &mut s) {
+ return w;
+ }
+ }
+ String::new()
+ }
+}
diff --git a/lcci/17.15.Longest Word/Solution.swift b/lcci/17.15.Longest Word/Solution.swift
index f05b1fc22864c..008d82149d0be 100644
--- a/lcci/17.15.Longest Word/Solution.swift
+++ b/lcci/17.15.Longest Word/Solution.swift
@@ -1,57 +1,35 @@
-class Trie {
- var children = [Trie?](repeating: nil, count: 26)
- var isEnd = false
-
- func insert(_ word: String) {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- node.children[index] = Trie()
+class Solution {
+ func longestWord(_ words: [String]) -> String {
+ var s: Set = Set(words)
+ var words = words
+ words.sort { (a, b) -> Bool in
+ if a.count == b.count {
+ return a < b
+ } else {
+ return a.count > b.count
}
- node = node.children[index]!
}
- node.isEnd = true
- }
- func search(_ word: String) -> Bool {
- var node = self
- for ch in word {
- let index = Int(ch.asciiValue! - Character("a").asciiValue!)
- if node.children[index] == nil {
- return false
- }
- node = node.children[index]!
- }
- return node.isEnd
- }
-}
-
-class Solution {
- func longestWord(_ words: [String]) -> String {
- var words = words.sorted(by: { $0.count < $1.count || ($0.count == $1.count && $0 > $1) })
- let trie = Trie()
-
- var dfs: ((String) -> Bool)!
- dfs = { w in
+ func dfs(_ w: String) -> Bool {
if w.isEmpty {
return true
}
- for i in 1...w.count {
- if trie.search(String(w.prefix(i))) && dfs(String(w.suffix(w.count - i))) {
+ for k in 1...w.count {
+ let prefix = String(w.prefix(k))
+ if s.contains(prefix) && dfs(String(w.dropFirst(k))) {
return true
}
}
return false
}
-
- var ans = ""
+
for w in words {
+ s.remove(w)
if dfs(w) {
- ans = w
+ return w
}
- trie.insert(w)
}
- return ans
+
+ return ""
}
}
diff --git a/lcci/17.15.Longest Word/Solution.ts b/lcci/17.15.Longest Word/Solution.ts
new file mode 100644
index 0000000000000..1dc4862412162
--- /dev/null
+++ b/lcci/17.15.Longest Word/Solution.ts
@@ -0,0 +1,26 @@
+function longestWord(words: string[]): string {
+ const s = new Set(words);
+
+ words.sort((a, b) => (a.length === b.length ? a.localeCompare(b) : b.length - a.length));
+
+ const dfs = (w: string): boolean => {
+ if (w === '') {
+ return true;
+ }
+ for (let k = 1; k <= w.length; ++k) {
+ if (s.has(w.substring(0, k)) && dfs(w.substring(k))) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ for (const w of words) {
+ s.delete(w);
+ if (dfs(w)) {
+ return w;
+ }
+ }
+
+ return '';
+}
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23011. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23011. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227/README.md"
index ad4c6421ed926..f238a9a8c0e5a 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23011. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23011. \346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\346\225\260\345\255\227/README.md"
@@ -46,7 +46,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9
- `numbers[mid] > numbers[r]`:中间元素一定不是最小值,因此 $l = mid + 1$;
- `numbers[mid] < numbers[r]`:中间元素可能是最小值,因此 $r = mid$;
-- `numbers[mid] == numbers[r]`:中间元素一定不是最小值,因此 $r = r - 1$。
+- `numbers[mid] == numbers[r]`:无法确定最小值的位置,但可以简单地缩小搜索范围,因此 $r = r - 1$。
循环结束时,指针 $l$ 和 $r$ 指向同一个元素,即为最小值。
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23020. \350\241\250\347\244\272\346\225\260\345\200\274\347\232\204\345\255\227\347\254\246\344\270\262/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23020. \350\241\250\347\244\272\346\225\260\345\200\274\347\232\204\345\255\227\347\254\246\344\270\262/README.md"
index f2eb26a4d88c1..539be1dbe3691 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23020. \350\241\250\347\244\272\346\225\260\345\200\274\347\232\204\345\255\227\347\254\246\344\270\262/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23020. \350\241\250\347\244\272\346\225\260\345\200\274\347\232\204\345\255\227\347\254\246\344\270\262/README.md"
@@ -111,7 +111,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9
遍历 $s[i,..j]$ 范围内的每个字符,根据字符的类型进行分类讨论:
-- 如果当前字符是 `+` 或者 `-`,那么该字符的前一个字符必须是 `e` 或者 `E`,或者空格,否则返回 `false`。
+- 如果当前字符是 `+` 或者 `-`,那么该字符必须是第一个有效字符(即空格后的第一个非空字符),或者该字符的前一个字符必须是 `e` 或者 `E`,否则返回 `false`。
- 如果当前字符是数字,那么我们将 `digit` 置为 `true`。
- 如果当前字符是 `.`,那么该字符之前不能出现过 `.` 或者 `e`/`E`,否则返回 `false`,否则我们将 `dot` 置为 `true`。
- 如果当前字符是 `e` 或者 `E`,那么该字符之前不能出现过 `e`/`E`,并且必须出现过数字,否则返回 `false`,否则我们将 `e` 置为 `true`,并且将 `digit` 置为 `false`,表示 `e` 之后必须出现数字。
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23026. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23026. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204/README.md"
index d82afb7073ebb..357589c016e2d 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23026. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23026. \346\240\221\347\232\204\345\255\220\347\273\223\346\236\204/README.md"
@@ -60,7 +60,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9
1. 如果树 B 为空,则树 B 是树 A 的子结构,返回 `true`;
2. 如果树 A 为空,或者树 A 的根节点的值不等于树 B 的根节点的值,则树 B 不是树 A 的子结构,返回 `false`;
-3. 判断树 A 的左子树是否包含树 B,即调用 $\textit{dfs}(A.left, B)$,并且判断树 A 的右子树是否包含树 B,即调用 $\textit{dfs}(A.right, B)$。如果其中有一个函数返回 `false`,则树 B 不是树 A 的子结构,返回 `false`;否则,返回 `true`。
+3. 判断树 A 的左子树是否包含树 B 的左子树,即调用 $\textit{dfs}(A.left, B.left)$,并且判断树 A 的右子树是否包含树 B 的右子树,即调用 $\textit{dfs}(A.right, B.right)$。如果其中有一个函数返回 `false`,则树 B 不是树 A 的子结构,返回 `false`;否则,返回 `true`。
在函数 `isSubStructure` 中,我们首先判断树 A 和树 B 是否为空,如果其中有一个为空,则树 B 不是树 A 的子结构,返回 `false`。然后,我们调用 $\textit{dfs}(A, B)$,判断树 A 是否包含树 B。如果是,则返回 `true`;否则,递归判断树 A 的左子树是否包含树 B,以及树 A 的右子树是否包含树 B。如果其中有一个返回 `true`,则树 B 是树 A 的子结构,返回 `true`;否则,返回 `false`。
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23044. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23044. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227/README.md"
index 9305b97a146e7..3b8e96c4f1e5e 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23044. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23044. \346\225\260\345\255\227\345\272\217\345\210\227\344\270\255\346\237\220\344\270\200\344\275\215\347\232\204\346\225\260\345\255\227/README.md"
@@ -12,7 +12,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9
-数字以0123456789101112131415…的格式序列化到一个字符序列中。在这个序列中,第5位(从下标0开始计数)是5,第13位是1,第19位是4,等等。
+数字以123456789101112131415…的格式序列化到一个字符序列中。在这个序列中,第5位是5,第13位是1,第19位是4,等等。
请写一个函数,求任意第n位对应的数字。
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23046. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23046. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262/README.md"
index 98773024f9f8a..f0442ed4c037a 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23046. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23046. \346\212\212\346\225\260\345\255\227\347\277\273\350\257\221\346\210\220\345\255\227\347\254\246\344\270\262/README.md"
@@ -40,12 +40,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9
我们先将数字 `num` 转为字符串 $s$,字符串 $s$ 的长度记为 $n$。
-然后我们设计一个函数 $dfs(i)$,表示从第 $i$ 个数字开始的不同翻译的数目。那么答案就是 $dfs(0)$。
+然后我们设计一个函数 $dfs(i)$,表示从索引为 $i$ 的数字开始的不同翻译的数目。那么答案就是 $dfs(0)$。
函数 $dfs(i)$ 的计算如下:
-- 如果 $i \ge n - 1$,说明已经翻译到最后一个数字,只有一种翻译方法,返回 $1$;
-- 否则,我们可以选择翻译第 $i$ 个数字,此时翻译方法数目为 $dfs(i + 1)$;如果第 $i$ 个数字和第 $i + 1$ 个数字可以组成一个有效的字符(即 $s[i] == 1$ 或者 $s[i] == 2$ 且 $s[i + 1] \lt 6$),那么我们还可以选择翻译第 $i$ 和第 $i + 1$ 个数字,此时翻译方法数目为 $dfs(i + 2)$。因此 $dfs(i) = dfs(i+1) + dfs(i+2)$。
+- 如果 $i \ge n - 1$,说明已经翻译到最后一个数字或者越过最后一个字符,均只有一种翻译方法,返回 $1$;
+- 否则,我们可以选择翻译索引为 $i$ 的数字,此时翻译方法数目为 $dfs(i + 1)$;如果索引为 $i$ 的数字和索引为 $i + 1$ 的数字可以组成一个有效的字符(即 $s[i] == 1$ 或者 $s[i] == 2$ 且 $s[i + 1] \lt 6$),那么我们还可以选择翻译索引为 $i$ 和索引为 $i + 1$ 的数字,此时翻译方法数目为 $dfs(i + 2)$。因此 $dfs(i) = dfs(i+1) + dfs(i+2)$。
过程中我们可以使用记忆化搜索,将已经计算过的 $dfs(i)$ 的值存储起来,避免重复计算。
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/README.md"
index ebe212c8fb7b0..1edfd50f307a8 100644
--- "a/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/README.md"
+++ "b/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/README.md"
@@ -143,6 +143,46 @@ class Solution {
}
```
+#### C++
+
+```cpp
+class Solution {
+public:
+ int strToInt(string str) {
+ int res = 0, bndry = INT_MAX / 10;
+ int i = 0, sign = 1, length = str.size();
+ if (length == 0) {
+ return 0;
+ }
+ // 删除首部空格
+ while (str[i] == ' ') {
+ if (++i == length) {
+ return 0;
+ }
+ }
+ // 若有负号则标识符号位
+ if (str[i] == '-') {
+ sign = -1;
+ }
+ if (str[i] == '-' || str[i] == '+') {
+ i++;
+ }
+ for (int j = i; j < length; j++) {
+ if (str[j] < '0' || str[j] > '9') {
+ break;
+ }
+ // res>214748364越界;res=214748364且str[j] > '7'越界
+ if (res > bndry || res == bndry && str[j] > '7') {
+ return sign == 1 ? INT_MAX : INT_MIN;
+ }
+ // 从左向右遍历数字并更新结果
+ res = res * 10 + (str[j] - '0');
+ }
+ return sign * res;
+ }
+};
+```
+
#### Go
```go
diff --git "a/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/Solution.cpp" "b/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/Solution.cpp"
new file mode 100644
index 0000000000000..c392b7ddcbd1f
--- /dev/null
+++ "b/lcof/\351\235\242\350\257\225\351\242\23067. \346\212\212\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242\346\210\220\346\225\264\346\225\260/Solution.cpp"
@@ -0,0 +1,35 @@
+class Solution {
+public:
+ int strToInt(string str) {
+ int res = 0, bndry = INT_MAX / 10;
+ int i = 0, sign = 1, length = str.size();
+ if (length == 0) {
+ return 0;
+ }
+ // 删除首部空格
+ while (str[i] == ' ') {
+ if (++i == length) {
+ return 0;
+ }
+ }
+ // 若有负号则标识符号位
+ if (str[i] == '-') {
+ sign = -1;
+ }
+ if (str[i] == '-' || str[i] == '+') {
+ i++;
+ }
+ for (int j = i; j < length; j++) {
+ if (str[j] < '0' || str[j] > '9') {
+ break;
+ }
+ // res>214748364越界;res=214748364且str[j] > '7'越界
+ if (res > bndry || res == bndry && str[j] > '7') {
+ return sign == 1 ? INT_MAX : INT_MIN;
+ }
+ // 从左向右遍历数字并更新结果
+ res = res * 10 + (str[j] - '0');
+ }
+ return sign * res;
+ }
+};
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md"
index 0a7445246a6a8..dd18ee74ba2eb 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md"
@@ -69,9 +69,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof2/%E5%89%91%E6%8C%87%2
#### Python3
```python
-from sortedcontainers import SortedSet
-
-
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
s = SortedSet()
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py" "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py"
index f7ec481ecdd5d..b0910923928e3 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py"
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedSet
-
-
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
s = SortedSet()
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md"
index a3933de14e03c..54acea6311fdc 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md"
@@ -65,9 +65,6 @@ MyCalendar.book(20, 30); // returns true ,第三个日程安排可以添加到
#### Python3
```python
-from sortedcontainers import SortedDict
-
-
class MyCalendar:
def __init__(self):
self.sd = SortedDict()
@@ -89,9 +86,6 @@ class MyCalendar:
#### Java
```java
-import java.util.Map;
-import java.util.TreeMap;
-
class MyCalendar {
private final TreeMap tm = new TreeMap<>();
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java"
index 3d04816dc4b2e..1bb41cffcc07f 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java"
@@ -1,6 +1,3 @@
-import java.util.Map;
-import java.util.TreeMap;
-
class MyCalendar {
private final TreeMap tm = new TreeMap<>();
@@ -25,4 +22,4 @@ public boolean book(int start, int end) {
/**
* Your MyCalendar object will be instantiated and called as such: MyCalendar
* obj = new MyCalendar(); boolean param_1 = obj.book(start,end);
- */
\ No newline at end of file
+ */
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py"
index a17617ab776e9..c04195aeb8688 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py"
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
class MyCalendar:
def __init__(self):
self.sd = SortedDict()
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/README.md"
index d4b88475a5771..47a5a72c995db 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/README.md"
@@ -277,6 +277,68 @@ func openLock(deadends []string, target string) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func openLock(_ deadends: [String], _ target: String) -> Int {
+ let deadSet = Set(deadends)
+ if deadSet.contains(target) || deadSet.contains("0000") {
+ return -1
+ }
+ if target == "0000" {
+ return 0
+ }
+
+ var visited = Set()
+ var queue = ["0000"]
+ visited.insert("0000")
+ var step = 0
+
+ while !queue.isEmpty {
+ step += 1
+ for _ in 0.. [String] {
+ var neighbors = [String]()
+ var chars = Array(lock)
+ for i in 0..<4 {
+ let original = chars[i]
+ chars[i] = prevChar(original)
+ neighbors.append(String(chars))
+ chars[i] = nextChar(original)
+ neighbors.append(String(chars))
+ chars[i] = original
+ }
+ return neighbors
+ }
+
+ private func prevChar(_ c: Character) -> Character {
+ return c == "0" ? "9" : Character(UnicodeScalar(c.asciiValue! - 1))
+ }
+
+ private func nextChar(_ c: Character) -> Character {
+ return c == "9" ? "0" : Character(UnicodeScalar(c.asciiValue! + 1))
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/Solution.swift"
new file mode 100644
index 0000000000000..f50451503b7f7
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 109. \345\274\200\345\257\206\347\240\201\351\224\201/Solution.swift"
@@ -0,0 +1,57 @@
+class Solution {
+ func openLock(_ deadends: [String], _ target: String) -> Int {
+ let deadSet = Set(deadends)
+ if deadSet.contains(target) || deadSet.contains("0000") {
+ return -1
+ }
+ if target == "0000" {
+ return 0
+ }
+
+ var visited = Set()
+ var queue = ["0000"]
+ visited.insert("0000")
+ var step = 0
+
+ while !queue.isEmpty {
+ step += 1
+ for _ in 0.. [String] {
+ var neighbors = [String]()
+ var chars = Array(lock)
+ for i in 0..<4 {
+ let original = chars[i]
+ chars[i] = prevChar(original)
+ neighbors.append(String(chars))
+ chars[i] = nextChar(original)
+ neighbors.append(String(chars))
+ chars[i] = original
+ }
+ return neighbors
+ }
+
+ private func prevChar(_ c: Character) -> Character {
+ return c == "0" ? "9" : Character(UnicodeScalar(c.asciiValue! - 1))
+ }
+
+ private func nextChar(_ c: Character) -> Character {
+ return c == "9" ? "0" : Character(UnicodeScalar(c.asciiValue! + 1))
+ }
+}
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/README.md"
index d836612be9356..cf5ad50bd1cd5 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/README.md"
@@ -189,6 +189,35 @@ func allPathsSourceTarget(graph [][]int) [][]int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var results = [[Int]]()
+ private var graph = [[Int]]()
+
+ func allPathsSourceTarget(_ graph: [[Int]]) -> [[Int]] {
+ self.graph = graph
+ var path = [0]
+ dfs(0, &path)
+ return results
+ }
+
+ private func dfs(_ node: Int, _ path: inout [Int]) {
+ if node == graph.count - 1 {
+ results.append(Array(path))
+ return
+ }
+
+ for next in graph[node] {
+ path.append(next)
+ dfs(next, &path)
+ path.removeLast()
+ }
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/Solution.swift"
new file mode 100644
index 0000000000000..687ea6eb06818
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 110. \346\211\200\346\234\211\350\267\257\345\276\204/Solution.swift"
@@ -0,0 +1,24 @@
+class Solution {
+ private var results = [[Int]]()
+ private var graph = [[Int]]()
+
+ func allPathsSourceTarget(_ graph: [[Int]]) -> [[Int]] {
+ self.graph = graph
+ var path = [0]
+ dfs(0, &path)
+ return results
+ }
+
+ private func dfs(_ node: Int, _ path: inout [Int]) {
+ if node == graph.count - 1 {
+ results.append(Array(path))
+ return
+ }
+
+ for next in graph[node] {
+ path.append(next)
+ dfs(next, &path)
+ path.removeLast()
+ }
+ }
+}
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/README.md"
index 50e3b501799b6..bee586df396e5 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/README.md"
@@ -292,6 +292,72 @@ func find(x int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var parent = [Int]()
+ private var weight = [Double]()
+
+ func calcEquation(
+ _ equations: [[String]],
+ _ values: [Double],
+ _ queries: [[String]]
+ ) -> [Double] {
+ let n = equations.count
+ parent = Array(0..<(n * 2))
+ weight = Array(repeating: 1.0, count: n * 2)
+
+ var map = [String: Int]()
+ var index = 0
+
+ for i in 0.. Int {
+ if parent[x] != x {
+ let origin = parent[x]
+ parent[x] = find(parent[x])
+ weight[x] *= weight[origin]
+ }
+ return parent[x]
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/Solution.swift"
new file mode 100644
index 0000000000000..084ab48d48fd5
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 111. \350\256\241\347\256\227\351\231\244\346\263\225/Solution.swift"
@@ -0,0 +1,61 @@
+class Solution {
+ private var parent = [Int]()
+ private var weight = [Double]()
+
+ func calcEquation(
+ _ equations: [[String]],
+ _ values: [Double],
+ _ queries: [[String]]
+ ) -> [Double] {
+ let n = equations.count
+ parent = Array(0..<(n * 2))
+ weight = Array(repeating: 1.0, count: n * 2)
+
+ var map = [String: Int]()
+ var index = 0
+
+ for i in 0.. Int {
+ if parent[x] != x {
+ let origin = parent[x]
+ parent[x] = find(parent[x])
+ weight[x] *= weight[origin]
+ }
+ return parent[x]
+ }
+}
\ No newline at end of file
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/README.md"
index 4e8337208369c..f878e8e0288b2 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/README.md"
@@ -205,6 +205,49 @@ func longestIncreasingPath(matrix [][]int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var memo: [[Int]] = []
+ private var matrix: [[Int]] = []
+ private var m: Int = 0
+ private var n: Int = 0
+
+ func longestIncreasingPath(_ matrix: [[Int]]) -> Int {
+ self.matrix = matrix
+ m = matrix.count
+ n = matrix[0].count
+ memo = Array(repeating: Array(repeating: -1, count: n), count: m)
+
+ var ans = 0
+ for i in 0.. Int {
+ if memo[i][j] != -1 {
+ return memo[i][j]
+ }
+ var ans = 1
+ let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
+
+ for (dx, dy) in dirs {
+ let x = i + dx, y = j + dy
+ if x >= 0, x < m, y >= 0, y < n, matrix[x][y] > matrix[i][j] {
+ ans = max(ans, dfs(x, y) + 1)
+ }
+ }
+ memo[i][j] = ans
+ return ans
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/Solution.swift"
new file mode 100644
index 0000000000000..a1bca0d1e6a02
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 112. \346\234\200\351\225\277\351\200\222\345\242\236\350\267\257\345\276\204/Solution.swift"
@@ -0,0 +1,38 @@
+class Solution {
+ private var memo: [[Int]] = []
+ private var matrix: [[Int]] = []
+ private var m: Int = 0
+ private var n: Int = 0
+
+ func longestIncreasingPath(_ matrix: [[Int]]) -> Int {
+ self.matrix = matrix
+ m = matrix.count
+ n = matrix[0].count
+ memo = Array(repeating: Array(repeating: -1, count: n), count: m)
+
+ var ans = 0
+ for i in 0.. Int {
+ if memo[i][j] != -1 {
+ return memo[i][j]
+ }
+ var ans = 1
+ let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
+
+ for (dx, dy) in dirs {
+ let x = i + dx, y = j + dy
+ if x >= 0, x < m, y >= 0, y < n, matrix[x][y] > matrix[i][j] {
+ ans = max(ans, dfs(x, y) + 1)
+ }
+ }
+ memo[i][j] = ans
+ return ans
+ }
+}
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/README.md"
index 52e72ae62a670..8fc55cbe257d2 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/README.md"
@@ -269,6 +269,46 @@ public class Solution {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func findOrder(_ numCourses: Int, _ prerequisites: [[Int]]) -> [Int] {
+ var graph = Array(repeating: [Int](), count: numCourses)
+ var indegree = Array(repeating: 0, count: numCourses)
+
+ for prereq in prerequisites {
+ let course = prereq[0]
+ let prereqCourse = prereq[1]
+ graph[prereqCourse].append(course)
+ indegree[course] += 1
+ }
+
+ var queue = [Int]()
+ for i in 0..
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/Solution.swift"
new file mode 100644
index 0000000000000..3bb5be6ec4b4d
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 113. \350\257\276\347\250\213\351\241\272\345\272\217/Solution.swift"
@@ -0,0 +1,35 @@
+class Solution {
+ func findOrder(_ numCourses: Int, _ prerequisites: [[Int]]) -> [Int] {
+ var graph = Array(repeating: [Int](), count: numCourses)
+ var indegree = Array(repeating: 0, count: numCourses)
+
+ for prereq in prerequisites {
+ let course = prereq[0]
+ let prereqCourse = prereq[1]
+ graph[prereqCourse].append(course)
+ indegree[course] += 1
+ }
+
+ var queue = [Int]()
+ for i in 0.. String {
+ var graph = Array(repeating: Set(), count: 26)
+ var indegree = Array(repeating: 0, count: 26)
+ var seen = Array(repeating: false, count: 26)
+ var letterCount = 0
+
+ for i in 0.. words[i + 1].count {
+ return ""
+ }
+ }
+ }
+
+ for char in words[words.count - 1] {
+ let index = Int(char.asciiValue! - Character("a").asciiValue!)
+ if !seen[index] {
+ seen[index] = true
+ letterCount += 1
+ }
+ }
+
+ var queue = [Int]()
+ for i in 0..<26 {
+ if seen[i] && indegree[i] == 0 {
+ queue.append(i)
+ }
+ }
+
+ var order = ""
+ while !queue.isEmpty {
+ let u = queue.removeFirst()
+ order += String(UnicodeScalar(u + Int(Character("a").asciiValue!))!)
+ for v in graph[u] {
+ indegree[v] -= 1
+ if indegree[v] == 0 {
+ queue.append(v)
+ }
+ }
+ }
+
+ return order.count == letterCount ? order : ""
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 114. \345\244\226\346\230\237\346\226\207\345\255\227\345\205\270/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 114. \345\244\226\346\230\237\346\226\207\345\255\227\345\205\270/Solution.swift"
new file mode 100644
index 0000000000000..8f6ed449fed7f
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 114. \345\244\226\346\230\237\346\226\207\345\255\227\345\205\270/Solution.swift"
@@ -0,0 +1,67 @@
+class Solution {
+ func alienOrder(_ words: [String]) -> String {
+ var graph = Array(repeating: Set(), count: 26)
+ var indegree = Array(repeating: 0, count: 26)
+ var seen = Array(repeating: false, count: 26)
+ var letterCount = 0
+
+ for i in 0.. words[i + 1].count {
+ return ""
+ }
+ }
+ }
+
+ for char in words[words.count - 1] {
+ let index = Int(char.asciiValue! - Character("a").asciiValue!)
+ if !seen[index] {
+ seen[index] = true
+ letterCount += 1
+ }
+ }
+
+ var queue = [Int]()
+ for i in 0..<26 {
+ if seen[i] && indegree[i] == 0 {
+ queue.append(i)
+ }
+ }
+
+ var order = ""
+ while !queue.isEmpty {
+ let u = queue.removeFirst()
+ order += String(UnicodeScalar(u + Int(Character("a").asciiValue!))!)
+ for v in graph[u] {
+ indegree[v] -= 1
+ if indegree[v] == 0 {
+ queue.append(v)
+ }
+ }
+ }
+
+ return order.count == letterCount ? order : ""
+ }
+}
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/README.md"
index 3f1b34527a0af..2b1f18bc59a6a 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/README.md"
@@ -250,6 +250,46 @@ function sequenceReconstruction(nums: number[], sequences: number[][]): boolean
}
```
+#### Swift
+
+```swift
+class Solution {
+ func sequenceReconstruction(_ nums: [Int], _ sequences: [[Int]]) -> Bool {
+ let n = nums.count
+ var indegree = [Int](repeating: 0, count: n)
+ var graph = Array(repeating: [Int](), count: n)
+
+ for sequence in sequences {
+ for i in 1..
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/Solution.swift"
new file mode 100644
index 0000000000000..16fc600079abb
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 115. \351\207\215\345\273\272\345\272\217\345\210\227/Solution.swift"
@@ -0,0 +1,35 @@
+class Solution {
+ func sequenceReconstruction(_ nums: [Int], _ sequences: [[Int]]) -> Bool {
+ let n = nums.count
+ var indegree = [Int](repeating: 0, count: n)
+ var graph = Array(repeating: [Int](), count: n)
+
+ for sequence in sequences {
+ for i in 1.. Int {
+ self.isConnected = isConnected
+ self.n = isConnected.count
+ self.visited = [Bool](repeating: false, count: n)
+ var numberOfCircles = 0
+
+ for i in 0..
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 116. \346\234\213\345\217\213\345\234\210/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 116. \346\234\213\345\217\213\345\234\210/Solution.swift"
new file mode 100644
index 0000000000000..b1e70c6aec534
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 116. \346\234\213\345\217\213\345\234\210/Solution.swift"
@@ -0,0 +1,29 @@
+class Solution {
+ private var isConnected: [[Int]] = []
+ private var visited: [Bool] = []
+ private var n: Int = 0
+
+ func findCircleNum(_ isConnected: [[Int]]) -> Int {
+ self.isConnected = isConnected
+ self.n = isConnected.count
+ self.visited = [Bool](repeating: false, count: n)
+ var numberOfCircles = 0
+
+ for i in 0.. Int {
+ let n = strs.count
+ parent = Array(0.. Bool {
+ let n = a.count
+ var count = 0
+ let arrA = Array(a), arrB = Array(b)
+
+ for i in 0.. 2 {
+ return false
+ }
+ }
+ return count <= 2
+ }
+
+ private func find(_ x: Int) -> Int {
+ if parent[x] != x {
+ parent[x] = find(parent[x])
+ }
+ return parent[x]
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 117. \347\233\270\344\274\274\347\232\204\345\255\227\347\254\246\344\270\262/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 117. \347\233\270\344\274\274\347\232\204\345\255\227\347\254\246\344\270\262/Solution.swift"
new file mode 100644
index 0000000000000..ac1f651a34e6b
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 117. \347\233\270\344\274\274\347\232\204\345\255\227\347\254\246\344\270\262/Solution.swift"
@@ -0,0 +1,47 @@
+class Solution {
+ private var parent: [Int] = []
+
+ func numSimilarGroups(_ strs: [String]) -> Int {
+ let n = strs.count
+ parent = Array(0.. Bool {
+ let n = a.count
+ var count = 0
+ let arrA = Array(a), arrB = Array(b)
+
+ for i in 0.. 2 {
+ return false
+ }
+ }
+ return count <= 2
+ }
+
+ private func find(_ x: Int) -> Int {
+ if parent[x] != x {
+ parent[x] = find(parent[x])
+ }
+ return parent[x]
+ }
+}
\ No newline at end of file
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/README.md"
index b9dda603f6065..25fa6655da072 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/README.md"
@@ -164,6 +164,36 @@ func findRedundantConnection(edges [][]int) []int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var parent: [Int] = []
+
+ func findRedundantConnection(_ edges: [[Int]]) -> [Int] {
+ parent = Array(0..<1010)
+
+ for edge in edges {
+ let a = edge[0]
+ let b = edge[1]
+
+ if find(a) == find(b) {
+ return edge
+ }
+ parent[find(a)] = find(b)
+ }
+ return []
+ }
+
+ private func find(_ x: Int) -> Int {
+ if parent[x] != x {
+ parent[x] = find(parent[x])
+ }
+ return parent[x]
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/Solution.swift"
new file mode 100644
index 0000000000000..5987e53a2b151
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 118. \345\244\232\344\275\231\347\232\204\350\276\271/Solution.swift"
@@ -0,0 +1,25 @@
+class Solution {
+ private var parent: [Int] = []
+
+ func findRedundantConnection(_ edges: [[Int]]) -> [Int] {
+ parent = Array(0..<1010)
+
+ for edge in edges {
+ let a = edge[0]
+ let b = edge[1]
+
+ if find(a) == find(b) {
+ return edge
+ }
+ parent[find(a)] = find(b)
+ }
+ return []
+ }
+
+ private func find(_ x: Int) -> Int {
+ if parent[x] != x {
+ parent[x] = find(parent[x])
+ }
+ return parent[x]
+ }
+}
\ No newline at end of file
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/README.md"
index c38278c1a11ec..91a2164a9c7f8 100644
--- "a/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/README.md"
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/README.md"
@@ -221,6 +221,34 @@ var longestConsecutive = function (nums) {
};
```
+#### Swift
+
+```swift
+class Solution {
+ func longestConsecutive(_ nums: [Int]) -> Int {
+ let n = nums.count
+ if n < 2 {
+ return n
+ }
+
+ let sortedNums = Array(Set(nums)).sorted()
+ var ans = 1
+ var currentStreak = 1
+
+ for i in 1..
@@ -360,6 +388,33 @@ var longestConsecutive = function (nums) {
};
```
+#### Swift
+
+```swift
+class Solution {
+ func longestConsecutive(_ nums: [Int]) -> Int {
+ let numSet: Set = Set(nums)
+ var longestStreak = 0
+
+ for num in nums {
+ if !numSet.contains(num - 1) {
+ var currentNum = num
+ var currentStreak = 1
+
+ while numSet.contains(currentNum + 1) {
+ currentNum += 1
+ currentStreak += 1
+ }
+
+ longestStreak = max(longestStreak, currentStreak)
+ }
+ }
+
+ return longestStreak
+ }
+}
+```
+
diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/Solution.swift" "b/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/Solution.swift"
new file mode 100644
index 0000000000000..ff42f1c5b1949
--- /dev/null
+++ "b/lcof2/\345\211\221\346\214\207 Offer II 119. \346\234\200\351\225\277\350\277\236\347\273\255\345\272\217\345\210\227/Solution.swift"
@@ -0,0 +1,23 @@
+class Solution {
+ func longestConsecutive(_ nums: [Int]) -> Int {
+ let n = nums.count
+ if n < 2 {
+ return n
+ }
+
+ let sortedNums = Array(Set(nums)).sorted()
+ var ans = 1
+ var currentStreak = 1
+
+ for i in 1.. Int {
+ let numSet: Set = Set(nums)
+ var longestStreak = 0
+
+ for num in nums {
+ if !numSet.contains(num - 1) {
+ var currentNum = num
+ var currentStreak = 1
+
+ while numSet.contains(currentNum + 1) {
+ currentNum += 1
+ currentStreak += 1
+ }
+
+ longestStreak = max(longestStreak, currentStreak)
+ }
+ }
+
+ return longestStreak
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/README.md" "b/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/README.md"
index 27eaab2822b7b..4ddf53357c988 100644
--- "a/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/README.md"
+++ "b/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/README.md"
@@ -155,6 +155,22 @@ int game(int* guess, int guessSize, int* answer, int answerSize) {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func game(_ guess: [Int], _ answer: [Int]) -> Int {
+ var correctGuesses = 0
+ for i in 0..<3 {
+ if guess[i] == answer[i] {
+ correctGuesses += 1
+ }
+ }
+ return correctGuesses
+ }
+}
+```
+
diff --git "a/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/Solution.swift" "b/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/Solution.swift"
new file mode 100644
index 0000000000000..23f55f3b0e31d
--- /dev/null
+++ "b/lcp/LCP 01. \347\214\234\346\225\260\345\255\227/Solution.swift"
@@ -0,0 +1,11 @@
+class Solution {
+ func game(_ guess: [Int], _ answer: [Int]) -> Int {
+ var correctGuesses = 0
+ for i in 0..<3 {
+ if guess[i] == answer[i] {
+ correctGuesses += 1
+ }
+ }
+ return correctGuesses
+ }
+}
diff --git "a/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/README.md" "b/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/README.md"
index f2c5e01372cdd..c819541cadd16 100644
--- "a/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/README.md"
+++ "b/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/README.md"
@@ -195,6 +195,36 @@ var fraction = function (cont) {
};
```
+#### Swift
+
+```swift
+class Solution {
+ private var cont: [Int] = []
+
+ func fraction(_ cont: [Int]) -> [Int] {
+ self.cont = cont
+ return dfs(0)
+ }
+
+ private func dfs(_ i: Int) -> [Int] {
+ if i == cont.count - 1 {
+ return [cont[i], 1]
+ }
+ let next = dfs(i + 1)
+ let a = next[0]
+ let b = next[1]
+ let x = a * cont[i] + b
+ let y = a
+ let g = gcd(x, y)
+ return [x / g, y / g]
+ }
+
+ private func gcd(_ a: Int, _ b: Int) -> Int {
+ return b == 0 ? a : gcd(b, a % b)
+ }
+}
+```
+
diff --git "a/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/Solution.swift" "b/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/Solution.swift"
new file mode 100644
index 0000000000000..90097779be77a
--- /dev/null
+++ "b/lcp/LCP 02. \345\210\206\345\274\217\345\214\226\347\256\200/Solution.swift"
@@ -0,0 +1,25 @@
+class Solution {
+ private var cont: [Int] = []
+
+ func fraction(_ cont: [Int]) -> [Int] {
+ self.cont = cont
+ return dfs(0)
+ }
+
+ private func dfs(_ i: Int) -> [Int] {
+ if i == cont.count - 1 {
+ return [cont[i], 1]
+ }
+ let next = dfs(i + 1)
+ let a = next[0]
+ let b = next[1]
+ let x = a * cont[i] + b
+ let y = a
+ let g = gcd(x, y)
+ return [x / g, y / g]
+ }
+
+ private func gcd(_ a: Int, _ b: Int) -> Int {
+ return b == 0 ? a : gcd(b, a % b)
+ }
+}
diff --git "a/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md" "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
index c086edd1b0eb7..4a10c79e9ade4 100644
--- "a/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
+++ "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
@@ -239,6 +239,49 @@ function robot(command: string, obstacles: number[][], x: number, y: number): bo
}
```
+#### Swift
+
+```swift
+class Solution {
+ func robot(_ command: String, _ obstacles: [[Int]], _ x: Int, _ y: Int) -> Bool {
+ var visited: Set<[Int]> = []
+ var i = 0, j = 0
+ visited.insert([i, j])
+
+ for c in command {
+ if c == "U" {
+ j += 1
+ } else {
+ i += 1
+ }
+ visited.insert([i, j])
+ }
+
+ func canReach(_ targetX: Int, _ targetY: Int) -> Bool {
+ let k = min(targetX / i, targetY / j)
+ return visited.contains([targetX - k * i, targetY - k * j])
+ }
+
+ if !canReach(x, y) {
+ return false
+ }
+
+ for obstacle in obstacles {
+ let obstacleX = obstacle[0]
+ let obstacleY = obstacle[1]
+ if obstacleX > x || obstacleY > y {
+ continue
+ }
+ if canReach(obstacleX, obstacleY) {
+ return false
+ }
+ }
+
+ return true
+ }
+}
+```
+
diff --git "a/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/Solution.swift" "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/Solution.swift"
new file mode 100644
index 0000000000000..7f8aebe2c5231
--- /dev/null
+++ "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/Solution.swift"
@@ -0,0 +1,38 @@
+class Solution {
+ func robot(_ command: String, _ obstacles: [[Int]], _ x: Int, _ y: Int) -> Bool {
+ var visited: Set<[Int]> = []
+ var i = 0, j = 0
+ visited.insert([i, j])
+
+ for c in command {
+ if c == "U" {
+ j += 1
+ } else {
+ i += 1
+ }
+ visited.insert([i, j])
+ }
+
+ func canReach(_ targetX: Int, _ targetY: Int) -> Bool {
+ let k = min(targetX / i, targetY / j)
+ return visited.contains([targetX - k * i, targetY - k * j])
+ }
+
+ if !canReach(x, y) {
+ return false
+ }
+
+ for obstacle in obstacles {
+ let obstacleX = obstacle[0]
+ let obstacleY = obstacle[1]
+ if obstacleX > x || obstacleY > y {
+ continue
+ }
+ if canReach(obstacleX, obstacleY) {
+ return false
+ }
+ }
+
+ return true
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 05. \345\217\221 LeetCoin/README.md" "b/lcp/LCP 05. \345\217\221 LeetCoin/README.md"
index 6402769f54b27..fad40a20eceae 100644
--- "a/lcp/LCP 05. \345\217\221 LeetCoin/README.md"
+++ "b/lcp/LCP 05. \345\217\221 LeetCoin/README.md"
@@ -449,6 +449,144 @@ public:
};
```
+#### Swift
+
+```swift
+class Node {
+ var left: Node?
+ var right: Node?
+ let l: Int
+ let r: Int
+ let mid: Int
+ var v = 0
+ var add = 0
+
+ init(_ l: Int, _ r: Int) {
+ self.l = l
+ self.r = r
+ self.mid = (l + r) >> 1
+ }
+}
+
+class SegmentTree {
+ private var root: Node
+ private let MOD = 1_000_000_007
+
+ init(_ n: Int) {
+ root = Node(1, n)
+ }
+
+ func modify(_ l: Int, _ r: Int, _ v: Int) {
+ modify(l, r, v, root)
+ }
+
+ private func modify(_ l: Int, _ r: Int, _ v: Int, _ node: Node) {
+ if l > r {
+ return
+ }
+ if node.l >= l && node.r <= r {
+ node.v = (node.v + (node.r - node.l + 1) * v) % MOD
+ node.add = (node.add + v) % MOD
+ return
+ }
+ pushdown(node)
+ if l <= node.mid {
+ modify(l, r, v, node.left!)
+ }
+ if r > node.mid {
+ modify(l, r, v, node.right!)
+ }
+ pushup(node)
+ }
+
+ func query(_ l: Int, _ r: Int) -> Int {
+ return query(l, r, root)
+ }
+
+ private func query(_ l: Int, _ r: Int, _ node: Node) -> Int {
+ if l > r {
+ return 0
+ }
+ if node.l >= l && node.r <= r {
+ return node.v
+ }
+ pushdown(node)
+ var v = 0
+ if l <= node.mid {
+ v = (v + query(l, r, node.left!)) % MOD
+ }
+ if r > node.mid {
+ v = (v + query(l, r, node.right!)) % MOD
+ }
+ return v
+ }
+
+ private func pushup(_ node: Node) {
+ node.v = (node.left!.v + node.right!.v) % MOD
+ }
+
+ private func pushdown(_ node: Node) {
+ if node.left == nil {
+ node.left = Node(node.l, node.mid)
+ }
+ if node.right == nil {
+ node.right = Node(node.mid + 1, node.r)
+ }
+ if node.add != 0 {
+ let left = node.left!, right = node.right!
+ left.v = (left.v + (left.r - left.l + 1) * node.add) % MOD
+ right.v = (right.v + (right.r - right.l + 1) * node.add) % MOD
+ left.add = (left.add + node.add) % MOD
+ right.add = (right.add + node.add) % MOD
+ node.add = 0
+ }
+ }
+}
+
+class Solution {
+ private var g: [[Int]] = []
+ private var begin: [Int] = []
+ private var end: [Int] = []
+ private var idx = 1
+
+ func bonus(_ n: Int, _ leadership: [[Int]], _ operations: [[Int]]) -> [Int] {
+ g = Array(repeating: [], count: n + 1)
+ for l in leadership {
+ let (a, b) = (l[0], l[1])
+ g[a].append(b)
+ }
+
+ begin = Array(repeating: 0, count: n + 1)
+ end = Array(repeating: 0, count: n + 1)
+ idx = 1
+ dfs(1)
+
+ var ans: [Int] = []
+ let tree = SegmentTree(n)
+ for op in operations {
+ let (p, v) = (op[0], op[1])
+ if p == 1 {
+ tree.modify(begin[v], begin[v], op[2])
+ } else if p == 2 {
+ tree.modify(begin[v], end[v], op[2])
+ } else if p == 3 {
+ ans.append(tree.query(begin[v], end[v]))
+ }
+ }
+ return ans
+ }
+
+ private func dfs(_ u: Int) {
+ begin[u] = idx
+ for v in g[u] {
+ dfs(v)
+ }
+ end[u] = idx
+ idx += 1
+ }
+}
+```
+
diff --git "a/lcp/LCP 05. \345\217\221 LeetCoin/Solution.swift" "b/lcp/LCP 05. \345\217\221 LeetCoin/Solution.swift"
new file mode 100644
index 0000000000000..52937b2979ad8
--- /dev/null
+++ "b/lcp/LCP 05. \345\217\221 LeetCoin/Solution.swift"
@@ -0,0 +1,133 @@
+class Node {
+ var left: Node?
+ var right: Node?
+ let l: Int
+ let r: Int
+ let mid: Int
+ var v = 0
+ var add = 0
+
+ init(_ l: Int, _ r: Int) {
+ self.l = l
+ self.r = r
+ self.mid = (l + r) >> 1
+ }
+}
+
+class SegmentTree {
+ private var root: Node
+ private let MOD = 1_000_000_007
+
+ init(_ n: Int) {
+ root = Node(1, n)
+ }
+
+ func modify(_ l: Int, _ r: Int, _ v: Int) {
+ modify(l, r, v, root)
+ }
+
+ private func modify(_ l: Int, _ r: Int, _ v: Int, _ node: Node) {
+ if l > r {
+ return
+ }
+ if node.l >= l && node.r <= r {
+ node.v = (node.v + (node.r - node.l + 1) * v) % MOD
+ node.add = (node.add + v) % MOD
+ return
+ }
+ pushdown(node)
+ if l <= node.mid {
+ modify(l, r, v, node.left!)
+ }
+ if r > node.mid {
+ modify(l, r, v, node.right!)
+ }
+ pushup(node)
+ }
+
+ func query(_ l: Int, _ r: Int) -> Int {
+ return query(l, r, root)
+ }
+
+ private func query(_ l: Int, _ r: Int, _ node: Node) -> Int {
+ if l > r {
+ return 0
+ }
+ if node.l >= l && node.r <= r {
+ return node.v
+ }
+ pushdown(node)
+ var v = 0
+ if l <= node.mid {
+ v = (v + query(l, r, node.left!)) % MOD
+ }
+ if r > node.mid {
+ v = (v + query(l, r, node.right!)) % MOD
+ }
+ return v
+ }
+
+ private func pushup(_ node: Node) {
+ node.v = (node.left!.v + node.right!.v) % MOD
+ }
+
+ private func pushdown(_ node: Node) {
+ if node.left == nil {
+ node.left = Node(node.l, node.mid)
+ }
+ if node.right == nil {
+ node.right = Node(node.mid + 1, node.r)
+ }
+ if node.add != 0 {
+ let left = node.left!, right = node.right!
+ left.v = (left.v + (left.r - left.l + 1) * node.add) % MOD
+ right.v = (right.v + (right.r - right.l + 1) * node.add) % MOD
+ left.add = (left.add + node.add) % MOD
+ right.add = (right.add + node.add) % MOD
+ node.add = 0
+ }
+ }
+}
+
+class Solution {
+ private var g: [[Int]] = []
+ private var begin: [Int] = []
+ private var end: [Int] = []
+ private var idx = 1
+
+ func bonus(_ n: Int, _ leadership: [[Int]], _ operations: [[Int]]) -> [Int] {
+ g = Array(repeating: [], count: n + 1)
+ for l in leadership {
+ let (a, b) = (l[0], l[1])
+ g[a].append(b)
+ }
+
+ begin = Array(repeating: 0, count: n + 1)
+ end = Array(repeating: 0, count: n + 1)
+ idx = 1
+ dfs(1)
+
+ var ans: [Int] = []
+ let tree = SegmentTree(n)
+ for op in operations {
+ let (p, v) = (op[0], op[1])
+ if p == 1 {
+ tree.modify(begin[v], begin[v], op[2])
+ } else if p == 2 {
+ tree.modify(begin[v], end[v], op[2])
+ } else if p == 3 {
+ ans.append(tree.query(begin[v], end[v]))
+ }
+ }
+ return ans
+ }
+
+ private func dfs(_ u: Int) {
+ begin[u] = idx
+ for v in g[u] {
+ dfs(v)
+ }
+ end[u] = idx
+ idx += 1
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md" "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md"
index a13eeebc8f399..fd1f297a5456f 100644
--- "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md"
+++ "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md"
@@ -154,6 +154,20 @@ int minCount(int* coins, int coinsSize) {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func minCount(_ coins: [Int]) -> Int {
+ var ans = 0
+ for x in coins {
+ ans += (x + 1) >> 1
+ }
+ return ans
+ }
+}
+```
+
diff --git "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.swift" "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.swift"
new file mode 100644
index 0000000000000..9b88a97b003b4
--- /dev/null
+++ "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.swift"
@@ -0,0 +1,9 @@
+class Solution {
+ func minCount(_ coins: [Int]) -> Int {
+ var ans = 0
+ for x in coins {
+ ans += (x + 1) >> 1
+ }
+ return ans
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md" "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md"
index 1703fe246c239..f3a58cc62caa7 100644
--- "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md"
+++ "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md"
@@ -155,6 +155,25 @@ function numWays(n: number, relation: number[][], k: number): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func numWays(_ n: Int, _ relation: [[Int]], _ k: Int) -> Int {
+ var f = Array(repeating: Array(repeating: 0, count: n), count: k + 1)
+ f[0][0] = 1
+
+ for i in 1...k {
+ for r in relation {
+ let a = r[0], b = r[1]
+ f[i][b] += f[i - 1][a]
+ }
+ }
+ return f[k][n - 1]
+ }
+}
+```
+
@@ -255,6 +274,30 @@ function numWays(n: number, relation: number[][], k: number): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func numWays(_ n: Int, _ relation: [[Int]], _ k: Int) -> Int {
+ var f = Array(repeating: 0, count: n)
+ f[0] = 1
+ var steps = k
+
+ while steps > 0 {
+ var g = Array(repeating: 0, count: n)
+ for r in relation {
+ let a = r[0], b = r[1]
+ g[b] += f[a]
+ }
+ f = g
+ steps -= 1
+ }
+
+ return f[n - 1]
+ }
+}
+```
+
diff --git "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution.swift" "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution.swift"
new file mode 100644
index 0000000000000..c652759ac9adf
--- /dev/null
+++ "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution.swift"
@@ -0,0 +1,14 @@
+class Solution {
+ func numWays(_ n: Int, _ relation: [[Int]], _ k: Int) -> Int {
+ var f = Array(repeating: Array(repeating: 0, count: n), count: k + 1)
+ f[0][0] = 1
+
+ for i in 1...k {
+ for r in relation {
+ let a = r[0], b = r[1]
+ f[i][b] += f[i - 1][a]
+ }
+ }
+ return f[k][n - 1]
+ }
+}
diff --git "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution2.swift" "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution2.swift"
new file mode 100644
index 0000000000000..b62995acf5a39
--- /dev/null
+++ "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/Solution2.swift"
@@ -0,0 +1,19 @@
+class Solution {
+ func numWays(_ n: Int, _ relation: [[Int]], _ k: Int) -> Int {
+ var f = Array(repeating: 0, count: n)
+ f[0] = 1
+ var steps = k
+
+ while steps > 0 {
+ var g = Array(repeating: 0, count: n)
+ for r in relation {
+ let a = r[0], b = r[1]
+ g[b] += f[a]
+ }
+ f = g
+ steps -= 1
+ }
+
+ return f[n - 1]
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md" "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md"
index 7f3a754caf57c..f29879959c9dc 100644
--- "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md"
+++ "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/README.md"
@@ -140,6 +140,47 @@ class Solution {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func getTriggerTime(_ increase: [[Int]], _ requirements: [[Int]]) -> [Int] {
+ let m = increase.count, n = requirements.count
+ var s = Array(repeating: [0, 0, 0], count: m + 1)
+
+ for i in 0.. Bool {
+ for i in 0..<3 {
+ if a[i] < b[i] {
+ return false
+ }
+ }
+ return true
+ }
+}
+```
+
diff --git "a/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift" "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift"
new file mode 100644
index 0000000000000..1b2606567fd06
--- /dev/null
+++ "b/lcp/LCP 08. \345\211\247\346\203\205\350\247\246\345\217\221\346\227\266\351\227\264/Solution.swift"
@@ -0,0 +1,36 @@
+class Solution {
+ func getTriggerTime(_ increase: [[Int]], _ requirements: [[Int]]) -> [Int] {
+ let m = increase.count, n = requirements.count
+ var s = Array(repeating: [0, 0, 0], count: m + 1)
+
+ for i in 0.. Bool {
+ for i in 0..<3 {
+ if a[i] < b[i] {
+ return false
+ }
+ }
+ return true
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md" "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md"
index 570853993406f..02c7840200690 100644
--- "a/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md"
+++ "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md"
@@ -178,6 +178,50 @@ func minJump(jump []int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func minJump(_ jump: [Int]) -> Int {
+ let n = jump.count
+ var vis = Array(repeating: false, count: n)
+ var queue = [0]
+ vis[0] = true
+ var ans = 0
+ var maxReach = 1
+
+ while !queue.isEmpty {
+ ans += 1
+ let size = queue.count
+
+ for _ in 0..= n {
+ return ans
+ }
+
+ if !vis[forwardJump] {
+ queue.append(forwardJump)
+ vis[forwardJump] = true
+ }
+
+ while maxReach < i {
+ if !vis[maxReach] {
+ queue.append(maxReach)
+ vis[maxReach] = true
+ }
+ maxReach += 1
+ }
+ }
+ }
+
+ return -1
+ }
+}
+```
+
diff --git "a/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/Solution.swift" "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/Solution.swift"
new file mode 100644
index 0000000000000..cb4693fc17269
--- /dev/null
+++ "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/Solution.swift"
@@ -0,0 +1,39 @@
+class Solution {
+ func minJump(_ jump: [Int]) -> Int {
+ let n = jump.count
+ var vis = Array(repeating: false, count: n)
+ var queue = [0]
+ vis[0] = true
+ var ans = 0
+ var maxReach = 1
+
+ while !queue.isEmpty {
+ ans += 1
+ let size = queue.count
+
+ for _ in 0..= n {
+ return ans
+ }
+
+ if !vis[forwardJump] {
+ queue.append(forwardJump)
+ vis[forwardJump] = true
+ }
+
+ while maxReach < i {
+ if !vis[maxReach] {
+ queue.append(maxReach)
+ vis[maxReach] = true
+ }
+ maxReach += 1
+ }
+ }
+ }
+
+ return -1
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md" "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md"
index 217b12783b14e..88a761b550252 100644
--- "a/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md"
+++ "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md"
@@ -204,6 +204,43 @@ function minimalExecTime(root: TreeNode | null): number {
}
```
+#### Swift
+
+```swift
+/**
+* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init() { self.val = 0; self.left = nil; self.right = nil; }
+* public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+* public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ func minimalExecTime(_ root: TreeNode?) -> Double {
+ return dfs(root)[1]
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Double] {
+ guard let root = root else { return [0.0, 0.0] }
+
+ let left = dfs(root.left)
+ let right = dfs(root.right)
+
+ let sum = left[0] + right[0] + Double(root.val)
+ let time = max(max(left[1], right[1]), (left[0] + right[0]) / 2) + Double(root.val)
+
+ return [sum, time]
+ }
+}
+```
+
diff --git "a/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/Solution.swift" "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/Solution.swift"
new file mode 100644
index 0000000000000..d1449cfd0909d
--- /dev/null
+++ "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/Solution.swift"
@@ -0,0 +1,32 @@
+/**
+* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init() { self.val = 0; self.left = nil; self.right = nil; }
+* public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+* public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ func minimalExecTime(_ root: TreeNode?) -> Double {
+ return dfs(root)[1]
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Double] {
+ guard let root = root else { return [0.0, 0.0] }
+
+ let left = dfs(root.left)
+ let right = dfs(root.right)
+
+ let sum = left[0] + right[0] + Double(root.val)
+ let time = max(max(left[1], right[1]), (left[0] + right[0]) / 2) + Double(root.val)
+
+ return [sum, time]
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md" "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md"
index e9159c998fec7..62db68dcdb726 100644
--- "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md"
+++ "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/README.md"
@@ -125,6 +125,17 @@ function expectNumber(scores: number[]): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func expectNumber(_ scores: [Int]) -> Int {
+ let uniqueScores = Set(scores)
+ return uniqueScores.count
+ }
+}
+```
+
diff --git "a/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift" "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift"
new file mode 100644
index 0000000000000..af188317abaf1
--- /dev/null
+++ "b/lcp/LCP 11. \346\234\237\346\234\233\344\270\252\346\225\260\347\273\237\350\256\241/Solution.swift"
@@ -0,0 +1,6 @@
+class Solution {
+ func expectNumber(_ scores: [Int]) -> Int {
+ let uniqueScores = Set(scores)
+ return uniqueScores.count
+ }
+}
diff --git "a/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/README.md" "b/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/README.md"
index 42804b7024b0b..a2da6fe9ec4ef 100644
--- "a/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/README.md"
+++ "b/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/README.md"
@@ -217,6 +217,44 @@ function minTime(time: number[], m: number): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func minTime(_ time: [Int], _ m: Int) -> Int {
+ var left = 0
+ var right = time.reduce(0, +)
+
+ while left < right {
+ let mid = (left + right) / 2
+ if check(mid, time, m) {
+ right = mid
+ } else {
+ left = mid + 1
+ }
+ }
+ return left
+ }
+
+ private func check(_ t: Int, _ time: [Int], _ m: Int) -> Bool {
+ var sum = 0
+ var maxTime = 0
+ var days = 1
+
+ for x in time {
+ sum += x
+ maxTime = max(maxTime, x)
+ if sum - maxTime > t {
+ sum = x
+ maxTime = x
+ days += 1
+ }
+ }
+ return days <= m
+ }
+}
+```
+
diff --git "a/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/Solution.swift" "b/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/Solution.swift"
new file mode 100644
index 0000000000000..8213c97c09ac9
--- /dev/null
+++ "b/lcp/LCP 12. \345\260\217\345\274\240\345\210\267\351\242\230\350\256\241\345\210\222/Solution.swift"
@@ -0,0 +1,33 @@
+class Solution {
+ func minTime(_ time: [Int], _ m: Int) -> Int {
+ var left = 0
+ var right = time.reduce(0, +)
+
+ while left < right {
+ let mid = (left + right) / 2
+ if check(mid, time, m) {
+ right = mid
+ } else {
+ left = mid + 1
+ }
+ }
+ return left
+ }
+
+ private func check(_ t: Int, _ time: [Int], _ m: Int) -> Bool {
+ var sum = 0
+ var maxTime = 0
+ var days = 1
+
+ for x in time {
+ sum += x
+ maxTime = max(maxTime, x)
+ if sum - maxTime > t {
+ sum = x
+ maxTime = x
+ days += 1
+ }
+ }
+ return days <= m
+ }
+}
diff --git "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md" "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"
index ef691e227f58a..7c8136ef52536 100644
--- "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"
+++ "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/README.md"
@@ -118,6 +118,25 @@ func calculate(s string) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func calculate(_ s: String) -> Int {
+ var x = 1
+ var y = 0
+ for c in s {
+ if c == "A" {
+ x = x * 2 + y
+ } else if c == "B" {
+ y = y * 2 + x
+ }
+ }
+ return x + y
+ }
+}
+```
+
diff --git "a/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift" "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift"
new file mode 100644
index 0000000000000..d8f69186b0f44
--- /dev/null
+++ "b/lcp/LCP 17. \351\200\237\347\256\227\346\234\272\345\231\250\344\272\272/Solution.swift"
@@ -0,0 +1,14 @@
+class Solution {
+ func calculate(_ s: String) -> Int {
+ var x = 1
+ var y = 0
+ for c in s {
+ if c == "A" {
+ x = x * 2 + y
+ } else if c == "B" {
+ y = y * 2 + x
+ }
+ }
+ return x + y
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/README.md" "b/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/README.md"
index c04eb85dcb523..f57903fb90c8f 100644
--- "a/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/README.md"
+++ "b/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/README.md"
@@ -187,6 +187,37 @@ func breakfastNumber(staple []int, drinks []int, x int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func breakfastNumber(_ staple: [Int], _ drinks: [Int], _ x: Int) -> Int {
+ let mod = 1000000007
+ var result = 0
+ let sortedDrinks = drinks.sorted()
+
+ for s in staple {
+ let remaining = x - s
+ if remaining >= sortedDrinks.first ?? 0 {
+ var left = 0
+ var right = sortedDrinks.count - 1
+
+ while left < right {
+ let mid = (left + right + 1) / 2
+ if sortedDrinks[mid] <= remaining {
+ left = mid
+ } else {
+ right = mid - 1
+ }
+ }
+ result = (result + left + 1) % mod
+ }
+ }
+ return result
+ }
+}
+```
+
diff --git "a/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/Solution.swift" "b/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/Solution.swift"
new file mode 100644
index 0000000000000..f126c14fafca0
--- /dev/null
+++ "b/lcp/LCP 18. \346\227\251\351\244\220\347\273\204\345\220\210/Solution.swift"
@@ -0,0 +1,26 @@
+class Solution {
+ func breakfastNumber(_ staple: [Int], _ drinks: [Int], _ x: Int) -> Int {
+ let mod = 1000000007
+ var result = 0
+ let sortedDrinks = drinks.sorted()
+
+ for s in staple {
+ let remaining = x - s
+ if remaining >= sortedDrinks.first ?? 0 {
+ var left = 0
+ var right = sortedDrinks.count - 1
+
+ while left < right {
+ let mid = (left + right + 1) / 2
+ if sortedDrinks[mid] <= remaining {
+ left = mid
+ } else {
+ right = mid - 1
+ }
+ }
+ result = (result + left + 1) % mod
+ }
+ }
+ return result
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/README.md" "b/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/README.md"
index 5caceb7fe92ad..47753dabb0320 100644
--- "a/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/README.md"
+++ "b/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/README.md"
@@ -200,6 +200,35 @@ function minimumOperations(leaves: string): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func minimumOperations(_ leaves: String) -> Int {
+ let n = leaves.count
+ let inf = Int.max / 2
+ var f = Array(repeating: [inf, inf, inf], count: n)
+ let leavesArray = Array(leaves)
+
+ f[0][0] = leavesArray[0] == "r" ? 0 : 1
+
+ for i in 1..
diff --git "a/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/Solution.swift" "b/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/Solution.swift"
new file mode 100644
index 0000000000000..18c6f753b5f39
--- /dev/null
+++ "b/lcp/LCP 19. \347\247\213\345\217\266\346\224\266\350\227\217\351\233\206/Solution.swift"
@@ -0,0 +1,24 @@
+class Solution {
+ func minimumOperations(_ leaves: String) -> Int {
+ let n = leaves.count
+ let inf = Int.max / 2
+ var f = Array(repeating: [inf, inf, inf], count: n)
+ let leavesArray = Array(leaves)
+
+ f[0][0] = leavesArray[0] == "r" ? 0 : 1
+
+ for i in 1.. Int {
+ if k == 0 || k == n * n {
+ return 1
+ }
+
+ func combination(_ n: Int, _ r: Int) -> Int {
+ guard r <= n else { return 0 }
+ if r == 0 || r == n { return 1 }
+ var result = 1
+ for i in 0..
diff --git "a/lcp/LCP 22. \351\273\221\347\231\275\346\226\271\346\240\274\347\224\273/Solution.swift" "b/lcp/LCP 22. \351\273\221\347\231\275\346\226\271\346\240\274\347\224\273/Solution.swift"
new file mode 100644
index 0000000000000..cce487d748515
--- /dev/null
+++ "b/lcp/LCP 22. \351\273\221\347\231\275\346\226\271\346\240\274\347\224\273/Solution.swift"
@@ -0,0 +1,30 @@
+class Solution {
+ func paintingPlan(_ n: Int, _ k: Int) -> Int {
+ if k == 0 || k == n * n {
+ return 1
+ }
+
+ func combination(_ n: Int, _ r: Int) -> Int {
+ guard r <= n else { return 0 }
+ if r == 0 || r == n { return 1 }
+ var result = 1
+ for i in 0..)
+ }
+
+
+ if lowerHeap.count > upperHeap.count + 1 {
+ if let maxLower = lowerHeap.first {
+ lowerHeap.removeFirst()
+ upperHeap.append(maxLower)
+ sumLower -= maxLower
+ sumUpper += maxLower
+ upperHeap.sort()
+ }
+ }
+ }
+
+ func findMedian() -> Int {
+ if lowerHeap.count > upperHeap.count {
+ return lowerHeap.first ?? 0
+ } else if let minUpper = upperHeap.first, let maxLower = lowerHeap.first {
+ return (minUpper + maxLower) / 2
+ }
+ return 0
+ }
+
+ func cal() -> Int {
+ let median = findMedian()
+ var result = (sumUpper - median * upperHeap.count) + (median * lowerHeap.count - sumLower)
+ result %= mod
+ if result < 0 {
+ result += mod
+ }
+ return Int(result)
+ }
+}
+
+class Solution {
+ func numsGame(_ nums: [Int]) -> [Int] {
+ let n = nums.count
+ var result = [Int]()
+ let finder = MedianFinder()
+
+ for i in 0..
@@ -328,9 +403,6 @@ func (h *hp) Pop() any {
#### Python3
```python
-from sortedcontainers import SortedList
-
-
class Solution:
def numsGame(self, nums: List[int]) -> List[int]:
l = SortedList()
diff --git "a/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution.swift" "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution.swift"
new file mode 100644
index 0000000000000..ab634a1bb321d
--- /dev/null
+++ "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution.swift"
@@ -0,0 +1,70 @@
+class MedianFinder {
+ private var lowerHeap: [Int] = []
+ private var upperHeap: [Int] = []
+ private let mod = 1_000_000_007
+ private var sumLower = 0
+ private var sumUpper = 0
+
+ init() {}
+
+ func addNum(_ num: Int) {
+
+ upperHeap.append(num)
+ sumUpper += num
+ upperHeap.sort()
+
+
+ if let minUpper = upperHeap.first {
+ upperHeap.removeFirst()
+ lowerHeap.append(minUpper)
+ sumUpper -= minUpper
+ sumLower += minUpper
+ lowerHeap.sort(by: >)
+ }
+
+
+ if lowerHeap.count > upperHeap.count + 1 {
+ if let maxLower = lowerHeap.first {
+ lowerHeap.removeFirst()
+ upperHeap.append(maxLower)
+ sumLower -= maxLower
+ sumUpper += maxLower
+ upperHeap.sort()
+ }
+ }
+ }
+
+ func findMedian() -> Int {
+ if lowerHeap.count > upperHeap.count {
+ return lowerHeap.first ?? 0
+ } else if let minUpper = upperHeap.first, let maxLower = lowerHeap.first {
+ return (minUpper + maxLower) / 2
+ }
+ return 0
+ }
+
+ func cal() -> Int {
+ let median = findMedian()
+ var result = (sumUpper - median * upperHeap.count) + (median * lowerHeap.count - sumLower)
+ result %= mod
+ if result < 0 {
+ result += mod
+ }
+ return Int(result)
+ }
+}
+
+class Solution {
+ func numsGame(_ nums: [Int]) -> [Int] {
+ let n = nums.count
+ var result = [Int]()
+ let finder = MedianFinder()
+
+ for i in 0.. List[int]:
l = SortedList()
diff --git "a/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/README.md" "b/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/README.md"
index 0fc09493e32f4..e7790f0ff417a 100644
--- "a/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/README.md"
+++ "b/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/README.md"
@@ -193,6 +193,41 @@ function keyboard(k: number, n: number): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func keyboard(_ k: Int, _ n: Int) -> Int {
+ let mod = 1_000_000_007
+ var c = Array(repeating: Array(repeating: 0, count: k + 1), count: n + 1)
+ for i in 0...n {
+ c[i][0] = 1
+ }
+
+ for i in 1...n {
+ for j in 1...k {
+ c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod
+ }
+ }
+
+ var f = Array(repeating: Array(repeating: 0, count: 27), count: n + 1)
+ for j in 0..<27 {
+ f[0][j] = 1
+ }
+
+ for i in 1...n {
+ for j in 1..<27 {
+ for h in 0...min(i, k) {
+ f[i][j] = (f[i][j] + (f[i - h][j - 1] * c[i][h]) % mod) % mod
+ }
+ }
+ }
+
+ return f[n][26]
+ }
+}
+```
+
diff --git "a/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/Solution.swift" "b/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/Solution.swift"
new file mode 100644
index 0000000000000..195504b9dbbc6
--- /dev/null
+++ "b/lcp/LCP 25. \345\217\244\350\221\243\351\224\256\347\233\230/Solution.swift"
@@ -0,0 +1,30 @@
+class Solution {
+ func keyboard(_ k: Int, _ n: Int) -> Int {
+ let mod = 1_000_000_007
+ var c = Array(repeating: Array(repeating: 0, count: k + 1), count: n + 1)
+ for i in 0...n {
+ c[i][0] = 1
+ }
+
+ for i in 1...n {
+ for j in 1...k {
+ c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod
+ }
+ }
+
+ var f = Array(repeating: Array(repeating: 0, count: 27), count: n + 1)
+ for j in 0..<27 {
+ f[0][j] = 1
+ }
+
+ for i in 1...n {
+ for j in 1..<27 {
+ for h in 0...min(i, k) {
+ f[i][j] = (f[i][j] + (f[i - h][j - 1] * c[i][h]) % mod) % mod
+ }
+ }
+ }
+
+ return f[n][26]
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/README.md" "b/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/README.md"
index db74c352935f0..badc772c450f3 100644
--- "a/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/README.md"
+++ "b/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/README.md"
@@ -123,6 +123,31 @@ func purchasePlans(nums []int, target int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func purchasePlans(_ nums: [Int], _ target: Int) -> Int {
+ let mod = 1_000_000_007
+ let nums = nums.sorted()
+ var res = 0
+ var i = 0
+ var j = nums.count - 1
+
+ while i < j {
+ if nums[i] + nums[j] > target {
+ j -= 1
+ } else {
+ res = (res + j - i) % mod
+ i += 1
+ }
+ }
+
+ return res
+ }
+}
+```
+
diff --git "a/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/Solution.swift" "b/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/Solution.swift"
new file mode 100644
index 0000000000000..73add5edd350f
--- /dev/null
+++ "b/lcp/LCP 28. \351\207\207\350\264\255\346\226\271\346\241\210/Solution.swift"
@@ -0,0 +1,20 @@
+class Solution {
+ func purchasePlans(_ nums: [Int], _ target: Int) -> Int {
+ let mod = 1_000_000_007
+ let nums = nums.sorted()
+ var res = 0
+ var i = 0
+ var j = nums.count - 1
+
+ while i < j {
+ if nums[i] + nums[j] > target {
+ j -= 1
+ } else {
+ res = (res + j - i) % mod
+ i += 1
+ }
+ }
+
+ return res
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 33. \350\223\204\346\260\264/README.md" "b/lcp/LCP 33. \350\223\204\346\260\264/README.md"
index 6511af87a08b2..bdc39772a5041 100644
--- "a/lcp/LCP 33. \350\223\204\346\260\264/README.md"
+++ "b/lcp/LCP 33. \350\223\204\346\260\264/README.md"
@@ -168,6 +168,34 @@ function storeWater(bucket: number[], vat: number[]): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func storeWater(_ bucket: [Int], _ vat: [Int]) -> Int {
+ let maxVat = vat.max() ?? 0
+ if maxVat == 0 {
+ return 0
+ }
+
+ let n = vat.count
+ var ans = Int.max
+
+ for x in 1...maxVat {
+ var y = 0
+ for i in 0.. 0 {
+ y += max(0, (vat[i] + x - 1) / x - bucket[i])
+ }
+ }
+ ans = min(ans, x + y)
+ }
+
+ return ans
+ }
+}
+```
+
diff --git "a/lcp/LCP 33. \350\223\204\346\260\264/Solution.swift" "b/lcp/LCP 33. \350\223\204\346\260\264/Solution.swift"
new file mode 100644
index 0000000000000..c1ade70414605
--- /dev/null
+++ "b/lcp/LCP 33. \350\223\204\346\260\264/Solution.swift"
@@ -0,0 +1,23 @@
+class Solution {
+ func storeWater(_ bucket: [Int], _ vat: [Int]) -> Int {
+ let maxVat = vat.max() ?? 0
+ if maxVat == 0 {
+ return 0
+ }
+
+ let n = vat.count
+ var ans = Int.max
+
+ for x in 1...maxVat {
+ var y = 0
+ for i in 0.. 0 {
+ y += max(0, (vat[i] + x - 1) / x - bucket[i])
+ }
+ }
+ ans = min(ans, x + y)
+ }
+
+ return ans
+ }
+}
diff --git "a/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/README.md" "b/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/README.md"
index a4c75c656f380..fa21b935b0d5f 100644
--- "a/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/README.md"
+++ "b/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/README.md"
@@ -225,6 +225,49 @@ var maxValue = function (root, k) {
};
```
+#### Swift
+
+```swift
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+* init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ private var k: Int = 0
+
+ func maxValue(_ root: TreeNode?, _ k: Int) -> Int {
+ self.k = k
+ return dfs(root).max() ?? 0
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Int] {
+ var ans = [Int](repeating: 0, count: k + 1)
+ guard let root = root else {
+ return ans
+ }
+ let l = dfs(root.left)
+ let r = dfs(root.right)
+
+ ans[0] = (l.max() ?? 0) + (r.max() ?? 0)
+
+ for i in 0..
diff --git "a/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/Solution.swift" "b/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/Solution.swift"
new file mode 100644
index 0000000000000..f87a0e0b81867
--- /dev/null
+++ "b/lcp/LCP 34. \344\272\214\345\217\211\346\240\221\346\237\223\350\211\262/Solution.swift"
@@ -0,0 +1,38 @@
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+* init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ private var k: Int = 0
+
+ func maxValue(_ root: TreeNode?, _ k: Int) -> Int {
+ self.k = k
+ return dfs(root).max() ?? 0
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Int] {
+ var ans = [Int](repeating: 0, count: k + 1)
+ guard let root = root else {
+ return ans
+ }
+ let l = dfs(root.left)
+ let r = dfs(root.right)
+
+ ans[0] = (l.max() ?? 0) + (r.max() ?? 0)
+
+ for i in 0.. Int {
+ var count = [Int: Int]()
+
+ for row in source {
+ for num in row {
+ count[num, default: 0] += 1
+ }
+ }
+
+ for row in target {
+ for num in row {
+ count[num, default: 0] -= 1
+ }
+ }
+
+ var result = 0
+ for value in count.values {
+ result += abs(value)
+ }
+
+ return result / 2
+ }
+}
+```
+
diff --git "a/lcp/LCP 39. \346\227\240\344\272\272\346\234\272\346\226\271\351\230\265/Solution.swift" "b/lcp/LCP 39. \346\227\240\344\272\272\346\234\272\346\226\271\351\230\265/Solution.swift"
new file mode 100644
index 0000000000000..39e7bfdbe1f6f
--- /dev/null
+++ "b/lcp/LCP 39. \346\227\240\344\272\272\346\234\272\346\226\271\351\230\265/Solution.swift"
@@ -0,0 +1,24 @@
+class Solution {
+ func minimumSwitchingTimes(_ source: [[Int]], _ target: [[Int]]) -> Int {
+ var count = [Int: Int]()
+
+ for row in source {
+ for num in row {
+ count[num, default: 0] += 1
+ }
+ }
+
+ for row in target {
+ for num in row {
+ count[num, default: 0] -= 1
+ }
+ }
+
+ var result = 0
+ for value in count.values {
+ result += abs(value)
+ }
+
+ return result / 2
+ }
+}
diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md"
index 4e21105c919d4..1b44a5d0836b8 100644
--- "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md"
+++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/README.md"
@@ -235,6 +235,57 @@ function maxmiumScore(cards: number[], cnt: number): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func maximumScore(_ cards: [Int], _ cnt: Int) -> Int {
+ let sortedCards = cards.sorted()
+ let n = sortedCards.count
+ var ans = 0
+
+ for i in 0..= 0 ? maxScore : 0
+ }
+}
+```
+
diff --git "a/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift" "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift"
new file mode 100644
index 0000000000000..767c90eeef9df
--- /dev/null
+++ "b/lcp/LCP 40. \345\277\203\347\256\227\346\214\221\346\210\230/Solution.swift"
@@ -0,0 +1,46 @@
+class Solution {
+ func maximumScore(_ cards: [Int], _ cnt: Int) -> Int {
+ let sortedCards = cards.sorted()
+ let n = sortedCards.count
+ var ans = 0
+
+ for i in 0..= 0 ? maxScore : 0
+ }
+}
diff --git "a/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/README.md" "b/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/README.md"
index c3e7123e60f62..d449b83f732ca 100644
--- "a/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/README.md"
+++ "b/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/README.md"
@@ -292,6 +292,70 @@ func abs(x int) int {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var m = 0
+ private var n = 0
+ private var chessboard: [String] = []
+
+ func flipChess(_ chessboard: [String]) -> Int {
+ self.m = chessboard.count
+ self.n = chessboard[0].count
+ self.chessboard = chessboard
+ var ans = 0
+
+ for i in 0.. Int {
+ var queue: [[Int]] = [[i, j]]
+ var g = chessboard.map { Array($0) }
+ g[i][j] = "X"
+ var count = 0
+
+ while !queue.isEmpty {
+ let p = queue.removeFirst()
+ let i = p[0], j = p[1]
+
+ for a in -1...1 {
+ for b in -1...1 {
+ if a == 0 && b == 0 { continue }
+
+ var x = i + a, y = j + b
+ while x >= 0 && x < m && y >= 0 && y < n && g[x][y] == "O" {
+ x += a
+ y += b
+ }
+
+ if x >= 0 && x < m && y >= 0 && y < n && g[x][y] == "X" {
+ x -= a
+ y -= b
+ count += max(abs(x - i), abs(y - j))
+
+ while x != i || y != j {
+ g[x][y] = "X"
+ queue.append([x, y])
+ x -= a
+ y -= b
+ }
+ }
+ }
+ }
+ }
+ return count
+ }
+}
+```
+
diff --git "a/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/Solution.swift" "b/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/Solution.swift"
new file mode 100644
index 0000000000000..cee5297eac9ce
--- /dev/null
+++ "b/lcp/LCP 41. \351\273\221\347\231\275\347\277\273\350\275\254\346\243\213/Solution.swift"
@@ -0,0 +1,59 @@
+class Solution {
+ private var m = 0
+ private var n = 0
+ private var chessboard: [String] = []
+
+ func flipChess(_ chessboard: [String]) -> Int {
+ self.m = chessboard.count
+ self.n = chessboard[0].count
+ self.chessboard = chessboard
+ var ans = 0
+
+ for i in 0.. Int {
+ var queue: [[Int]] = [[i, j]]
+ var g = chessboard.map { Array($0) }
+ g[i][j] = "X"
+ var count = 0
+
+ while !queue.isEmpty {
+ let p = queue.removeFirst()
+ let i = p[0], j = p[1]
+
+ for a in -1...1 {
+ for b in -1...1 {
+ if a == 0 && b == 0 { continue }
+
+ var x = i + a, y = j + b
+ while x >= 0 && x < m && y >= 0 && y < n && g[x][y] == "O" {
+ x += a
+ y += b
+ }
+
+ if x >= 0 && x < m && y >= 0 && y < n && g[x][y] == "X" {
+ x -= a
+ y -= b
+ count += max(abs(x - i), abs(y - j))
+
+ while x != i || y != j {
+ g[x][y] = "X"
+ queue.append([x, y])
+ x -= a
+ y -= b
+ }
+ }
+ }
+ }
+ }
+ return count
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/README.md" "b/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/README.md"
index 7add041f2ff7d..49d539633884d 100644
--- "a/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/README.md"
+++ "b/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/README.md"
@@ -159,6 +159,38 @@ func dfs(root *TreeNode) {
}
```
+#### Swift
+
+```swift
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+* init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ private var uniqueColors: Set = []
+
+ func numColor(_ root: TreeNode?) -> Int {
+ dfs(root)
+ return uniqueColors.count
+ }
+
+ private func dfs(_ node: TreeNode?) {
+ guard let node = node else { return }
+ uniqueColors.insert(node.val)
+ dfs(node.left)
+ dfs(node.right)
+ }
+}
+```
+
diff --git "a/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/Solution.swift" "b/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/Solution.swift"
new file mode 100644
index 0000000000000..b1381f7de3fa0
--- /dev/null
+++ "b/lcp/LCP 44. \345\274\200\345\271\225\345\274\217\347\204\260\347\201\253/Solution.swift"
@@ -0,0 +1,27 @@
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+* init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ private var uniqueColors: Set = []
+
+ func numColor(_ root: TreeNode?) -> Int {
+ dfs(root)
+ return uniqueColors.count
+ }
+
+ private func dfs(_ node: TreeNode?) {
+ guard let node = node else { return }
+ uniqueColors.insert(node.val)
+ dfs(node.left)
+ dfs(node.right)
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/README.md" "b/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/README.md"
index 9dcc177c97925..154e2726e34b0 100644
--- "a/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/README.md"
+++ "b/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/README.md"
@@ -154,6 +154,27 @@ function giveGem(gem: number[], operations: number[][]): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func giveGem(_ gem: [Int], _ operations: [[Int]]) -> Int {
+ var gem = gem
+
+ for op in operations {
+ let x = op[0], y = op[1]
+ let v = gem[x] / 2
+ gem[y] += v
+ gem[x] -= v
+ }
+
+ let maxGem = gem.max() ?? 0
+ let minGem = gem.min() ?? 0
+ return maxGem - minGem
+ }
+}
+```
+
diff --git "a/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/Solution.swift" "b/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/Solution.swift"
new file mode 100644
index 0000000000000..bebc434bdcb70
--- /dev/null
+++ "b/lcp/LCP 50. \345\256\235\347\237\263\350\241\245\347\273\231/Solution.swift"
@@ -0,0 +1,16 @@
+class Solution {
+ func giveGem(_ gem: [Int], _ operations: [[Int]]) -> Int {
+ var gem = gem
+
+ for op in operations {
+ let x = op[0], y = op[1]
+ let v = gem[x] / 2
+ gem[y] += v
+ gem[x] -= v
+ }
+
+ let maxGem = gem.max() ?? 0
+ let minGem = gem.min() ?? 0
+ return maxGem - minGem
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/README.md" "b/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/README.md"
index 747f8cd273976..187bb6c186990 100644
--- "a/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/README.md"
+++ "b/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/README.md"
@@ -235,6 +235,46 @@ function perfectMenu(
}
```
+#### Swift
+
+```swift
+class Solution {
+ func perfectMenu(_ materials: [Int], _ cookbooks: [[Int]], _ attribute: [[Int]], _ limit: Int) -> Int {
+ let n = cookbooks.count
+ var ans = -1
+
+ for mask in 0..<(1 << n) {
+ var a = 0, b = 0
+ var cnt = [Int](repeating: 0, count: 5)
+
+ for i in 0..> i & 1) == 1 {
+ a += attribute[i][0]
+ b += attribute[i][1]
+ for j in 0.. materials[i] {
+ ok = false
+ break
+ }
+ }
+
+ if b >= limit && a > ans && ok {
+ ans = a
+ }
+ }
+
+ return ans
+ }
+}
+```
+
diff --git "a/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/Solution.swift" "b/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/Solution.swift"
new file mode 100644
index 0000000000000..fdf10537d0c5e
--- /dev/null
+++ "b/lcp/LCP 51. \347\203\271\351\245\252\346\226\231\347\220\206/Solution.swift"
@@ -0,0 +1,35 @@
+class Solution {
+ func perfectMenu(_ materials: [Int], _ cookbooks: [[Int]], _ attribute: [[Int]], _ limit: Int) -> Int {
+ let n = cookbooks.count
+ var ans = -1
+
+ for mask in 0..<(1 << n) {
+ var a = 0, b = 0
+ var cnt = [Int](repeating: 0, count: 5)
+
+ for i in 0..> i & 1) == 1 {
+ a += attribute[i][0]
+ b += attribute[i][1]
+ for j in 0.. materials[i] {
+ ok = false
+ break
+ }
+ }
+
+ if b >= limit && a > ans && ok {
+ ans = a
+ }
+ }
+
+ return ans
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md" "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md"
index 0acdbbff7b8c7..fd875e6061c85 100644
--- "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md"
+++ "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md"
@@ -89,9 +89,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcp/LCP%2052.%20%E4%BA%8C%
# self.left = None
# self.right = None
-from sortedcontainers import SortedList
-
-
class Solution:
def getNumber(self, root: Optional[TreeNode], ops: List[List[int]]) -> int:
def dfs(root):
@@ -762,6 +759,63 @@ class TreeSet {
}
```
+#### Swift
+
+```swift
+/* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init() { self.val = 0; self.left = nil; self.right = nil; }
+* public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+* public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ private var treeValues: [Int] = []
+
+ func getNumber(_ root: TreeNode?, _ ops: [[Int]]) -> Int {
+ collectValues(root)
+
+ treeValues.sort()
+
+ var ans = 0
+ for op in ops.reversed() {
+ let t = op[0]
+ let x = op[1]
+ let y = op[2]
+ var indicesToRemove: [Int] = []
+
+ for i in 0..= x && val <= y {
+ indicesToRemove.append(i)
+ ans += t
+ }
+ }
+
+ for index in indicesToRemove.reversed() {
+ treeValues.remove(at: index)
+ }
+ }
+
+ return ans
+ }
+
+ private func collectValues(_ root: TreeNode?) {
+ guard let root = root else { return }
+ treeValues.append(root.val)
+ collectValues(root.left)
+ collectValues(root.right)
+ }
+}
+```
+
diff --git "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py" "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py"
index 2e140bdb7fd66..fe7d41876e7c8 100644
--- "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py"
+++ "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py"
@@ -5,8 +5,6 @@
# self.left = None
# self.right = None
-from sortedcontainers import SortedList
-
class Solution:
def getNumber(self, root: Optional[TreeNode], ops: List[List[int]]) -> int:
diff --git "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.swift" "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.swift"
new file mode 100644
index 0000000000000..8889b49daaccf
--- /dev/null
+++ "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.swift"
@@ -0,0 +1,52 @@
+/* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init() { self.val = 0; self.left = nil; self.right = nil; }
+* public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }
+* public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ private var treeValues: [Int] = []
+
+ func getNumber(_ root: TreeNode?, _ ops: [[Int]]) -> Int {
+ collectValues(root)
+
+ treeValues.sort()
+
+ var ans = 0
+ for op in ops.reversed() {
+ let t = op[0]
+ let x = op[1]
+ let y = op[2]
+ var indicesToRemove: [Int] = []
+
+ for i in 0..= x && val <= y {
+ indicesToRemove.append(i)
+ ans += t
+ }
+ }
+
+ for index in indicesToRemove.reversed() {
+ treeValues.remove(at: index)
+ }
+ }
+
+ return ans
+ }
+
+ private func collectValues(_ root: TreeNode?) {
+ guard let root = root else { return }
+ treeValues.append(root.val)
+ collectValues(root.left)
+ collectValues(root.right)
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md" "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md"
index 27f4631c9505d..883d15a935e95 100644
--- "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md"
+++ "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/README.md"
@@ -137,6 +137,25 @@ function getMinimumTime(time: number[], fruits: number[][], limit: number): numb
}
```
+#### Swift
+
+```swift
+class Solution {
+ func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int {
+ var ans = 0
+
+ for fruit in fruits {
+ let index = fruit[0]
+ let num = fruit[1]
+
+ ans += ((num + limit - 1) / limit) * time[index]
+ }
+
+ return ans
+ }
+}
+```
+
diff --git "a/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift" "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift"
new file mode 100644
index 0000000000000..21781989e242d
--- /dev/null
+++ "b/lcp/LCP 55. \351\207\207\351\233\206\346\236\234\345\256\236/Solution.swift"
@@ -0,0 +1,14 @@
+class Solution {
+ func getMinimumTime(_ time: [Int], _ fruits: [[Int]], _ limit: Int) -> Int {
+ var ans = 0
+
+ for fruit in fruits {
+ let index = fruit[0]
+ let num = fruit[1]
+
+ ans += ((num + limit - 1) / limit) * time[index]
+ }
+
+ return ans
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/README.md" "b/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/README.md"
index b66d379ba9b7d..79d933a073abb 100644
--- "a/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/README.md"
+++ "b/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/README.md"
@@ -271,6 +271,57 @@ function conveyorBelt(matrix: string[], start: number[], end: number[]): number
}
```
+#### Swift
+
+```swift
+class Solution {
+ func conveyorBelt(_ matrix: [String], _ start: [Int], _ end: [Int]) -> Int {
+ let directions: [(Int, Int)] = [(-1, 0), (0, 1), (1, 0), (0, -1)]
+ let directionMap: [Character: Int] = ["^": 0, ">": 1, "v": 2, "<": 3]
+
+ let rows = matrix.count
+ let cols = matrix[0].count
+
+ var dist = Array(repeating: Array(repeating: Int.max, count: cols), count: rows)
+ var deque: [(Int, Int)] = []
+
+ dist[start[0]][start[1]] = 0
+ deque.append((start[0], start[1]))
+
+ while !deque.isEmpty {
+ let (i, j) = deque.removeFirst()
+
+ if i == end[0] && j == end[1] {
+ return dist[i][j]
+ }
+
+ for (k, (di, dj)) in directions.enumerated() {
+ let ni = i + di
+ let nj = j + dj
+
+ if ni >= 0 && ni < rows && nj >= 0 && nj < cols {
+ let currentChar = matrix[i][matrix[i].index(matrix[i].startIndex, offsetBy: j)]
+ let additionalCost = directionMap[currentChar] == k ? 0 : 1
+ let newDist = dist[i][j] + additionalCost
+
+ if newDist < dist[ni][nj] {
+ dist[ni][nj] = newDist
+
+ if additionalCost == 0 {
+ deque.insert((ni, nj), at: 0)
+ } else {
+ deque.append((ni, nj))
+ }
+ }
+ }
+ }
+ }
+
+ return -1
+ }
+}
+```
+
diff --git "a/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/Solution.swift" "b/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/Solution.swift"
new file mode 100644
index 0000000000000..49e38bff757e2
--- /dev/null
+++ "b/lcp/LCP 56. \344\277\241\347\211\251\344\274\240\351\200\201/Solution.swift"
@@ -0,0 +1,46 @@
+class Solution {
+ func conveyorBelt(_ matrix: [String], _ start: [Int], _ end: [Int]) -> Int {
+ let directions: [(Int, Int)] = [(-1, 0), (0, 1), (1, 0), (0, -1)]
+ let directionMap: [Character: Int] = ["^": 0, ">": 1, "v": 2, "<": 3]
+
+ let rows = matrix.count
+ let cols = matrix[0].count
+
+ var dist = Array(repeating: Array(repeating: Int.max, count: cols), count: rows)
+ var deque: [(Int, Int)] = []
+
+ dist[start[0]][start[1]] = 0
+ deque.append((start[0], start[1]))
+
+ while !deque.isEmpty {
+ let (i, j) = deque.removeFirst()
+
+ if i == end[0] && j == end[1] {
+ return dist[i][j]
+ }
+
+ for (k, (di, dj)) in directions.enumerated() {
+ let ni = i + di
+ let nj = j + dj
+
+ if ni >= 0 && ni < rows && nj >= 0 && nj < cols {
+ let currentChar = matrix[i][matrix[i].index(matrix[i].startIndex, offsetBy: j)]
+ let additionalCost = directionMap[currentChar] == k ? 0 : 1
+ let newDist = dist[i][j] + additionalCost
+
+ if newDist < dist[ni][nj] {
+ dist[ni][nj] = newDist
+
+ if additionalCost == 0 {
+ deque.insert((ni, nj), at: 0)
+ } else {
+ deque.append((ni, nj))
+ }
+ }
+ }
+ }
+ }
+
+ return -1
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md" "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md"
index 14bac274a24df..faf7cedef5e2f 100644
--- "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md"
+++ "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/README.md"
@@ -183,6 +183,31 @@ impl Solution {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func temperatureTrend(_ temperatureA: [Int], _ temperatureB: [Int]) -> Int {
+ var maxTrend = 0
+ var currentTrend = 0
+
+ for i in 0.. 0) {
+ currentTrend += 1
+ maxTrend = max(maxTrend, currentTrend)
+ } else {
+ currentTrend = 0
+ }
+ }
+
+ return maxTrend
+ }
+}
+```
+
diff --git "a/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift" "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift"
new file mode 100644
index 0000000000000..b0807755dc2a1
--- /dev/null
+++ "b/lcp/LCP 61. \346\260\224\346\270\251\345\217\230\345\214\226\350\266\213\345\212\277/Solution.swift"
@@ -0,0 +1,20 @@
+class Solution {
+ func temperatureTrend(_ temperatureA: [Int], _ temperatureB: [Int]) -> Int {
+ var maxTrend = 0
+ var currentTrend = 0
+
+ for i in 0.. 0) {
+ currentTrend += 1
+ maxTrend = max(maxTrend, currentTrend)
+ } else {
+ currentTrend = 0
+ }
+ }
+
+ return maxTrend
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/README.md" "b/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/README.md"
index 348f106b5e995..690d01b9e1c20 100644
--- "a/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/README.md"
+++ "b/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/README.md"
@@ -205,6 +205,41 @@ function transportationHub(path: number[][]): number {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func transportationHub(_ path: [[Int]]) -> Int {
+ var inDegree = [Int: Int]()
+ var outDegree = [Int: Int]()
+ var nodeSet = Set()
+ var visitedEdges = Set()
+
+ for p in path {
+ let a = p[0]
+ let b = p[1]
+ let edgeKey = "\(a)-\(b)"
+
+ if !visitedEdges.contains(edgeKey) {
+ visitedEdges.insert(edgeKey)
+ nodeSet.insert(a)
+ nodeSet.insert(b)
+ inDegree[b, default: 0] += 1
+ outDegree[a, default: 0] += 1
+ }
+ }
+
+ for node in nodeSet {
+ if inDegree[node, default: 0] == nodeSet.count - 1 && outDegree[node, default: 0] == 0 {
+ return node
+ }
+ }
+
+ return -1
+ }
+}
+```
+
diff --git "a/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/Solution.swift" "b/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/Solution.swift"
new file mode 100644
index 0000000000000..dca4332f4a733
--- /dev/null
+++ "b/lcp/LCP 62. \344\272\244\351\200\232\346\236\242\347\272\275/Solution.swift"
@@ -0,0 +1,30 @@
+class Solution {
+ func transportationHub(_ path: [[Int]]) -> Int {
+ var inDegree = [Int: Int]()
+ var outDegree = [Int: Int]()
+ var nodeSet = Set()
+ var visitedEdges = Set()
+
+ for p in path {
+ let a = p[0]
+ let b = p[1]
+ let edgeKey = "\(a)-\(b)"
+
+ if !visitedEdges.contains(edgeKey) {
+ visitedEdges.insert(edgeKey)
+ nodeSet.insert(a)
+ nodeSet.insert(b)
+ inDegree[b, default: 0] += 1
+ outDegree[a, default: 0] += 1
+ }
+ }
+
+ for node in nodeSet {
+ if inDegree[node, default: 0] == nodeSet.count - 1 && outDegree[node, default: 0] == 0 {
+ return node
+ }
+ }
+
+ return -1
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/README.md" "b/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/README.md"
index 2d2823b8085a5..87edf23ce9852 100644
--- "a/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/README.md"
+++ "b/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/README.md"
@@ -274,6 +274,80 @@ func ballGame(num int, plate []string) (ans [][]int) {
}
```
+#### Swift
+
+```swift
+class Solution {
+ private var plate: [String] = []
+ private var num: Int = 0
+ private var m: Int = 0
+ private var n: Int = 0
+ private let dirs = [0, 1, 0, -1, 0]
+
+ func ballGame(_ num: Int, _ plate: [String]) -> [[Int]] {
+ self.num = num
+ self.plate = plate
+ self.m = plate.count
+ self.n = plate[0].count
+ var ans: [[Int]] = []
+
+ for i in 1.. Bool {
+ var k = num
+ var i = i, j = j, d = d
+
+ while plate[i][j] != "O" {
+ if k == 0 {
+ return false
+ }
+
+ if plate[i][j] == "W" {
+ d = (d + 3) % 4
+ } else if plate[i][j] == "E" {
+ d = (d + 1) % 4
+ }
+
+ i += dirs[d]
+ j += dirs[d + 1]
+
+ if i < 0 || i >= m || j < 0 || j >= n {
+ return false
+ }
+
+ k -= 1
+ }
+
+ return true
+ }
+}
+
+private extension String {
+ subscript(_ index: Int) -> Character {
+ return self[self.index(self.startIndex, offsetBy: index)]
+ }
+}
+```
+
diff --git "a/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/Solution.swift" "b/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/Solution.swift"
new file mode 100644
index 0000000000000..6a9b7c2f07875
--- /dev/null
+++ "b/lcp/LCP 63. \345\274\271\347\217\240\346\270\270\346\210\217/Solution.swift"
@@ -0,0 +1,69 @@
+class Solution {
+ private var plate: [String] = []
+ private var num: Int = 0
+ private var m: Int = 0
+ private var n: Int = 0
+ private let dirs = [0, 1, 0, -1, 0]
+
+ func ballGame(_ num: Int, _ plate: [String]) -> [[Int]] {
+ self.num = num
+ self.plate = plate
+ self.m = plate.count
+ self.n = plate[0].count
+ var ans: [[Int]] = []
+
+ for i in 1.. Bool {
+ var k = num
+ var i = i, j = j, d = d
+
+ while plate[i][j] != "O" {
+ if k == 0 {
+ return false
+ }
+
+ if plate[i][j] == "W" {
+ d = (d + 3) % 4
+ } else if plate[i][j] == "E" {
+ d = (d + 1) % 4
+ }
+
+ i += dirs[d]
+ j += dirs[d + 1]
+
+ if i < 0 || i >= m || j < 0 || j >= n {
+ return false
+ }
+
+ k -= 1
+ }
+
+ return true
+ }
+}
+
+private extension String {
+ subscript(_ index: Int) -> Character {
+ return self[self.index(self.startIndex, offsetBy: index)]
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/README.md" "b/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/README.md"
index 248022131b176..f1e53e794c997 100644
--- "a/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/README.md"
+++ "b/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/README.md"
@@ -258,6 +258,59 @@ func closeLampInTree(root *TreeNode) (ans int) {
}
```
+#### Swift
+
+```swift
+/* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ func closeLampInTree(_ root: TreeNode?) -> Int {
+ return dfs(root)[0]
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Int] {
+ var ans = [Int](repeating: 0, count: 4)
+ guard let root = root else {
+ return ans
+ }
+
+ let left = dfs(root.left)
+ let right = dfs(root.right)
+
+ let l1 = left[0], l2 = left[1], l3 = left[2], l4 = left[3]
+ let r1 = right[0], r2 = right[1], r3 = right[2], r4 = right[3]
+
+ if root.val != 0 {
+ ans[0] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 1, l4 + r4 + 3)
+ ans[1] = min(l1 + r1 + 2, l2 + r2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[2] = min(l1 + r1, l2 + r2 + 2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[3] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 3, l4 + r4 + 1)
+ } else {
+ ans[0] = min(l1 + r1, l2 + r2 + 2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[1] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 3, l4 + r4 + 1)
+ ans[2] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 1, l4 + r4 + 3)
+ ans[3] = min(l1 + r1 + 2, l2 + r2, l3 + r3 + 2, l4 + r4 + 2)
+ }
+
+ return ans
+ }
+
+ private func min(_ nums: Int...) -> Int {
+ return nums.min() ?? Int.max
+ }
+}
+```
+
diff --git "a/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/Solution.swift" "b/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/Solution.swift"
new file mode 100644
index 0000000000000..af2daef730b5a
--- /dev/null
+++ "b/lcp/LCP 64. \344\272\214\345\217\211\346\240\221\347\201\257\351\245\260/Solution.swift"
@@ -0,0 +1,48 @@
+/* public class TreeNode {
+* public var val: Int
+* public var left: TreeNode?
+* public var right: TreeNode?
+* public init(_ val: Int) {
+* self.val = val
+* self.left = nil
+* self.right = nil
+* }
+* }
+*/
+
+class Solution {
+ func closeLampInTree(_ root: TreeNode?) -> Int {
+ return dfs(root)[0]
+ }
+
+ private func dfs(_ root: TreeNode?) -> [Int] {
+ var ans = [Int](repeating: 0, count: 4)
+ guard let root = root else {
+ return ans
+ }
+
+ let left = dfs(root.left)
+ let right = dfs(root.right)
+
+ let l1 = left[0], l2 = left[1], l3 = left[2], l4 = left[3]
+ let r1 = right[0], r2 = right[1], r3 = right[2], r4 = right[3]
+
+ if root.val != 0 {
+ ans[0] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 1, l4 + r4 + 3)
+ ans[1] = min(l1 + r1 + 2, l2 + r2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[2] = min(l1 + r1, l2 + r2 + 2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[3] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 3, l4 + r4 + 1)
+ } else {
+ ans[0] = min(l1 + r1, l2 + r2 + 2, l3 + r3 + 2, l4 + r4 + 2)
+ ans[1] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 3, l4 + r4 + 1)
+ ans[2] = min(l1 + r1 + 1, l2 + r2 + 1, l3 + r3 + 1, l4 + r4 + 3)
+ ans[3] = min(l1 + r1 + 2, l2 + r2, l3 + r3 + 2, l4 + r4 + 2)
+ }
+
+ return ans
+ }
+
+ private func min(_ nums: Int...) -> Int {
+ return nums.min() ?? Int.max
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/README.md" "b/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/README.md"
index b61565afd4889..734bad71eb452 100644
--- "a/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/README.md"
+++ "b/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/README.md"
@@ -151,6 +151,29 @@ func minNumBooths(demand []string) (ans int) {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func minNumBooths(_ demand: [String]) -> Int {
+ var maxBooths = [Int](repeating: 0, count: 26)
+
+ for day in demand {
+ var dailyCount = [Int](repeating: 0, count: 26)
+ for char in day {
+ let index = Int(char.asciiValue! - Character("a").asciiValue!)
+ dailyCount[index] += 1
+ }
+ for i in 0..<26 {
+ maxBooths[i] = max(maxBooths[i], dailyCount[i])
+ }
+ }
+
+ return maxBooths.reduce(0, +)
+ }
+}
+```
+
diff --git "a/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/Solution.swift" "b/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/Solution.swift"
new file mode 100644
index 0000000000000..ba1b0d803592d
--- /dev/null
+++ "b/lcp/LCP 66. \346\234\200\345\260\217\345\261\225\345\217\260\346\225\260\351\207\217/Solution.swift"
@@ -0,0 +1,18 @@
+class Solution {
+ func minNumBooths(_ demand: [String]) -> Int {
+ var maxBooths = [Int](repeating: 0, count: 26)
+
+ for day in demand {
+ var dailyCount = [Int](repeating: 0, count: 26)
+ for char in day {
+ let index = Int(char.asciiValue! - Character("a").asciiValue!)
+ dailyCount[index] += 1
+ }
+ for i in 0..<26 {
+ maxBooths[i] = max(maxBooths[i], dailyCount[i])
+ }
+ }
+
+ return maxBooths.reduce(0, +)
+ }
+}
\ No newline at end of file
diff --git "a/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/README.md" "b/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/README.md"
index e4d4babb6c862..b2444818fc494 100644
--- "a/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/README.md"
+++ "b/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/README.md"
@@ -197,6 +197,46 @@ func expandBinaryTree(root *TreeNode) *TreeNode {
}
```
+#### Swift
+
+```swift
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+* init() { self.val = 0; self.left = nil; self.right = nil }
+* init(_ val: Int) { self.val = val; self.left = nil; self.right = nil }
+* init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ func expandBinaryTree(_ root: TreeNode?) -> TreeNode? {
+ return dfs(root)
+ }
+
+ private func dfs(_ root: TreeNode?) -> TreeNode? {
+ guard let root = root else { return nil }
+
+ let leftChild = dfs(root.left)
+ let rightChild = dfs(root.right)
+
+ if let leftChild = leftChild {
+ root.left = TreeNode(-1, leftChild, nil)
+ }
+ if let rightChild = rightChild {
+ root.right = TreeNode(-1, nil, rightChild)
+ }
+ return root
+ }
+}
+
+```
+
diff --git "a/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/Solution.swift" "b/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/Solution.swift"
new file mode 100644
index 0000000000000..56a1d82045ec9
--- /dev/null
+++ "b/lcp/LCP 67. \350\243\205\351\245\260\346\240\221/Solution.swift"
@@ -0,0 +1,36 @@
+/* class TreeNode {
+* var val: Int
+* var left: TreeNode?
+* var right: TreeNode?
+
+* init() { self.val = 0; self.left = nil; self.right = nil }
+* init(_ val: Int) { self.val = val; self.left = nil; self.right = nil }
+* init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
+* self.val = val
+* self.left = left
+* self.right = right
+* }
+* }
+*/
+
+class Solution {
+ func expandBinaryTree(_ root: TreeNode?) -> TreeNode? {
+ return dfs(root)
+ }
+
+ private func dfs(_ root: TreeNode?) -> TreeNode? {
+ guard let root = root else { return nil }
+
+ let leftChild = dfs(root.left)
+ let rightChild = dfs(root.right)
+
+ if let leftChild = leftChild {
+ root.left = TreeNode(-1, leftChild, nil)
+ }
+ if let rightChild = rightChild {
+ root.right = TreeNode(-1, nil, rightChild)
+ }
+
+ return root
+ }
+}
diff --git "a/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/README.md" "b/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/README.md"
index dca809e537dc9..ce88be9f1561f 100644
--- "a/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/README.md"
+++ "b/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/README.md"
@@ -150,6 +150,37 @@ func beautifulBouquet(flowers []int, cnt int) (ans int) {
}
```
+#### Swift
+
+```swift
+class Solution {
+ func beautifulBouquet(_ flowers: [Int], _ cnt: Int) -> Int {
+ let mod = Int(1e9 + 7)
+ var maxFlower = 0
+ for flower in flowers {
+ maxFlower = max(maxFlower, flower)
+ }
+
+ var flowerCount = [Int](repeating: 0, count: maxFlower + 1)
+ var ans = 0
+ var j = 0
+
+ for i in 0.. cnt {
+ flowerCount[flowers[j]] -= 1
+ j += 1
+ }
+
+ ans = (ans + (i - j + 1)) % mod
+ }
+
+ return ans
+ }
+}
+```
+
diff --git "a/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/Solution.swift" "b/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/Solution.swift"
new file mode 100644
index 0000000000000..c94b4a21c3413
--- /dev/null
+++ "b/lcp/LCP 68. \347\276\216\350\247\202\347\232\204\350\212\261\346\235\237/Solution.swift"
@@ -0,0 +1,26 @@
+class Solution {
+ func beautifulBouquet(_ flowers: [Int], _ cnt: Int) -> Int {
+ let mod = Int(1e9 + 7)
+ var maxFlower = 0
+ for flower in flowers {
+ maxFlower = max(maxFlower, flower)
+ }
+
+ var flowerCount = [Int](repeating: 0, count: maxFlower + 1)
+ var ans = 0
+ var j = 0
+
+ for i in 0.. cnt {
+ flowerCount[flowers[j]] -= 1
+ j += 1
+ }
+
+ ans = (ans + (i - j + 1)) % mod
+ }
+
+ return ans
+ }
+}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 93e256af88f15..734a405a7a3b2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,7 +8,7 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@prettier/plugin-php": "^0.22.2",
- "clang-format": "1.8.0",
+ "clang-format": "^1.8.0",
"husky": "^9.0.1",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
@@ -474,6 +474,7 @@
"resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.8.0.tgz",
"integrity": "sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw==",
"dev": true,
+ "license": "Apache-2.0",
"dependencies": {
"async": "^3.2.3",
"glob": "^7.0.0",
diff --git a/package.json b/package.json
index 3040f2fc33aac..a4f2c373c3278 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@prettier/plugin-php": "^0.22.2",
- "clang-format": "1.8.0",
+ "clang-format": "^1.8.0",
"husky": "^9.0.1",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
diff --git a/requirements.txt b/requirements.txt
index a861898c020f6..b87c0a5b8c9e6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
black==24.3.0
-Requests==2.32.0
\ No newline at end of file
+Requests==2.32.4
\ No newline at end of file
diff --git a/solution/0000-0099/0001.Two Sum/README.md b/solution/0000-0099/0001.Two Sum/README.md
index 48c03a89e9c22..88c20df42f7fa 100644
--- a/solution/0000-0099/0001.Two Sum/README.md
+++ b/solution/0000-0099/0001.Two Sum/README.md
@@ -85,8 +85,7 @@ class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
d = {}
for i, x in enumerate(nums):
- y = target - x
- if y in d:
+ if (y := target - x) in d:
return [d[y], i]
d[x] = i
```
@@ -302,6 +301,25 @@ def two_sum(nums, target)
end
```
+#### Kotlin
+
+```kotlin
+class Solution {
+ fun twoSum(nums: IntArray, target: Int): IntArray {
+ val m = mutableMapOf()
+ nums.forEachIndexed { i, x ->
+ val y = target - x
+ val j = m.get(y)
+ if (j != null) {
+ return intArrayOf(j, i)
+ }
+ m[x] = i
+ }
+ return intArrayOf()
+ }
+}
+```
+
#### Nim
```nim
@@ -318,22 +336,69 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
return @[]
```
-#### Kotlin
+#### Cangjie
-```kotlin
+```cj
class Solution {
- fun twoSum(nums: IntArray, target: Int): IntArray {
- val m = mutableMapOf()
- nums.forEachIndexed { i, x ->
- val y = target - x
- val j = m.get(y)
- if (j != null) {
- return intArrayOf(j, i)
+ func twoSum(nums: Array, target: Int64): Array {
+ let d = HashMap()
+ for (i in 0..nums.size) {
+ if (d.contains(target - nums[i])) {
+ return [d[target - nums[i]], i]
}
- m[x] = i
+ d[nums[i]] = i
}
- return intArrayOf()
+ []
+ }
+}
+```
+
+#### C
+
+```c
+#include
+
+int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
+ int capacity = 1;
+ while (capacity < numsSize * 2) capacity <<= 1;
+ int* keys = malloc(capacity * sizeof(int));
+ int* vals = malloc(capacity * sizeof(int));
+ char* used = calloc(capacity, sizeof(char));
+ if (!keys || !vals || !used) {
+ free(keys);
+ free(vals);
+ free(used);
+ *returnSize = 0;
+ return NULL;
+ }
+ for (int i = 0; i < numsSize; ++i) {
+ int x = nums[i];
+ int y = target - x;
+ unsigned int h = (unsigned int) y & (capacity - 1);
+ while (used[h]) {
+ if (keys[h] == y) {
+ int* res = malloc(2 * sizeof(int));
+ res[0] = vals[h];
+ res[1] = i;
+ *returnSize = 2;
+ free(keys);
+ free(vals);
+ free(used);
+ return res;
+ }
+ h = (h + 1) & (capacity - 1);
+ }
+ unsigned int h2 = (unsigned int) x & (capacity - 1);
+ while (used[h2]) h2 = (h2 + 1) & (capacity - 1);
+ used[h2] = 1;
+ keys[h2] = x;
+ vals[h2] = i;
}
+ *returnSize = 0;
+ free(keys);
+ free(vals);
+ free(used);
+ return NULL;
}
```
diff --git a/solution/0000-0099/0001.Two Sum/README_EN.md b/solution/0000-0099/0001.Two Sum/README_EN.md
index 38066a682c1f8..c536e027be740 100644
--- a/solution/0000-0099/0001.Two Sum/README_EN.md
+++ b/solution/0000-0099/0001.Two Sum/README_EN.md
@@ -82,8 +82,7 @@ class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
d = {}
for i, x in enumerate(nums):
- y = target - x
- if y in d:
+ if (y := target - x) in d:
return [d[y], i]
d[x] = i
```
@@ -299,6 +298,25 @@ def two_sum(nums, target)
end
```
+#### Kotlin
+
+```kotlin
+class Solution {
+ fun twoSum(nums: IntArray, target: Int): IntArray {
+ val m = mutableMapOf()
+ nums.forEachIndexed { i, x ->
+ val y = target - x
+ val j = m.get(y)
+ if (j != null) {
+ return intArrayOf(j, i)
+ }
+ m[x] = i
+ }
+ return intArrayOf()
+ }
+}
+```
+
#### Nim
```nim
@@ -315,22 +333,69 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
return @[]
```
-#### Kotlin
+#### Cangjie
-```kotlin
+```cj
class Solution {
- fun twoSum(nums: IntArray, target: Int): IntArray {
- val m = mutableMapOf()
- nums.forEachIndexed { i, x ->
- val y = target - x
- val j = m.get(y)
- if (j != null) {
- return intArrayOf(j, i)
+ func twoSum(nums: Array, target: Int64): Array {
+ let d = HashMap()
+ for (i in 0..nums.size) {
+ if (d.contains(target - nums[i])) {
+ return [d[target - nums[i]], i]
}
- m[x] = i
+ d[nums[i]] = i
}
- return intArrayOf()
+ []
+ }
+}
+```
+
+#### C
+
+```c
+#include
+
+int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
+ int capacity = 1;
+ while (capacity < numsSize * 2) capacity <<= 1;
+ int* keys = malloc(capacity * sizeof(int));
+ int* vals = malloc(capacity * sizeof(int));
+ char* used = calloc(capacity, sizeof(char));
+ if (!keys || !vals || !used) {
+ free(keys);
+ free(vals);
+ free(used);
+ *returnSize = 0;
+ return NULL;
+ }
+ for (int i = 0; i < numsSize; ++i) {
+ int x = nums[i];
+ int y = target - x;
+ unsigned int h = (unsigned int) y & (capacity - 1);
+ while (used[h]) {
+ if (keys[h] == y) {
+ int* res = malloc(2 * sizeof(int));
+ res[0] = vals[h];
+ res[1] = i;
+ *returnSize = 2;
+ free(keys);
+ free(vals);
+ free(used);
+ return res;
+ }
+ h = (h + 1) & (capacity - 1);
+ }
+ unsigned int h2 = (unsigned int) x & (capacity - 1);
+ while (used[h2]) h2 = (h2 + 1) & (capacity - 1);
+ used[h2] = 1;
+ keys[h2] = x;
+ vals[h2] = i;
}
+ *returnSize = 0;
+ free(keys);
+ free(vals);
+ free(used);
+ return NULL;
}
```
diff --git a/solution/0000-0099/0001.Two Sum/Solution.c b/solution/0000-0099/0001.Two Sum/Solution.c
new file mode 100644
index 0000000000000..5ed7119c426ee
--- /dev/null
+++ b/solution/0000-0099/0001.Two Sum/Solution.c
@@ -0,0 +1,44 @@
+#include
+
+int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
+ int capacity = 1;
+ while (capacity < numsSize * 2) capacity <<= 1;
+ int* keys = malloc(capacity * sizeof(int));
+ int* vals = malloc(capacity * sizeof(int));
+ char* used = calloc(capacity, sizeof(char));
+ if (!keys || !vals || !used) {
+ free(keys);
+ free(vals);
+ free(used);
+ *returnSize = 0;
+ return NULL;
+ }
+ for (int i = 0; i < numsSize; ++i) {
+ int x = nums[i];
+ int y = target - x;
+ unsigned int h = (unsigned int) y & (capacity - 1);
+ while (used[h]) {
+ if (keys[h] == y) {
+ int* res = malloc(2 * sizeof(int));
+ res[0] = vals[h];
+ res[1] = i;
+ *returnSize = 2;
+ free(keys);
+ free(vals);
+ free(used);
+ return res;
+ }
+ h = (h + 1) & (capacity - 1);
+ }
+ unsigned int h2 = (unsigned int) x & (capacity - 1);
+ while (used[h2]) h2 = (h2 + 1) & (capacity - 1);
+ used[h2] = 1;
+ keys[h2] = x;
+ vals[h2] = i;
+ }
+ *returnSize = 0;
+ free(keys);
+ free(vals);
+ free(used);
+ return NULL;
+}
diff --git a/solution/0000-0099/0001.Two Sum/Solution.cj b/solution/0000-0099/0001.Two Sum/Solution.cj
new file mode 100644
index 0000000000000..2ca66e33ab56d
--- /dev/null
+++ b/solution/0000-0099/0001.Two Sum/Solution.cj
@@ -0,0 +1,12 @@
+class Solution {
+ func twoSum(nums: Array, target: Int64): Array {
+ let d = HashMap()
+ for (i in 0..nums.size) {
+ if (d.contains(target - nums[i])) {
+ return [d[target - nums[i]], i]
+ }
+ d[nums[i]] = i
+ }
+ []
+ }
+}
diff --git a/solution/0000-0099/0001.Two Sum/Solution.py b/solution/0000-0099/0001.Two Sum/Solution.py
index 35a41d01ac455..5764f5daafd0e 100644
--- a/solution/0000-0099/0001.Two Sum/Solution.py
+++ b/solution/0000-0099/0001.Two Sum/Solution.py
@@ -2,7 +2,6 @@ class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
d = {}
for i, x in enumerate(nums):
- y = target - x
- if y in d:
+ if (y := target - x) in d:
return [d[y], i]
d[x] = i
diff --git a/solution/0000-0099/0002.Add Two Numbers/README.md b/solution/0000-0099/0002.Add Two Numbers/README.md
index 3806f64b53d17..6cda4e7ca4018 100644
--- a/solution/0000-0099/0002.Add Two Numbers/README.md
+++ b/solution/0000-0099/0002.Add Two Numbers/README.md
@@ -147,9 +147,9 @@ class Solution {
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
- ListNode* dummy = new ListNode();
+ ListNode dummy;
int carry = 0;
- ListNode* cur = dummy;
+ ListNode* cur = &dummy;
while (l1 || l2 || carry) {
int s = (l1 ? l1->val : 0) + (l2 ? l2->val : 0) + carry;
carry = s / 10;
@@ -158,7 +158,7 @@ public:
l1 = l1 ? l1->next : nullptr;
l2 = l2 ? l2->next : nullptr;
}
- return dummy->next;
+ return dummy.next;
}
};
```
@@ -494,6 +494,52 @@ proc addTwoNumbers(l1: var SinglyLinkedList, l2: var SinglyLinkedList): SinglyLi
result = aggregate
```
+#### C
+
+```c
+
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * struct ListNode *next;
+ * };
+ */
+
+struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
+ struct ListNode* dummy = (struct ListNode*) malloc(sizeof(struct ListNode));
+ dummy->val = 0;
+ dummy->next = NULL;
+ struct ListNode* curr = dummy;
+ int carry = 0;
+
+ while (l1 != NULL || l2 != NULL || carry != 0) {
+ int sum = carry;
+ if (l1 != NULL) {
+ sum += l1->val;
+ l1 = l1->next;
+ }
+ if (l2 != NULL) {
+ sum += l2->val;
+ l2 = l2->next;
+ }
+
+ carry = sum / 10;
+ int val = sum % 10;
+
+ struct ListNode* newNode = (struct ListNode*) malloc(sizeof(struct ListNode));
+ newNode->val = val;
+ newNode->next = NULL;
+ curr->next = newNode;
+ curr = curr->next;
+ }
+
+ struct ListNode* result = dummy->next;
+ free(dummy);
+ return result;
+}
+```
+
diff --git a/solution/0000-0099/0002.Add Two Numbers/README_EN.md b/solution/0000-0099/0002.Add Two Numbers/README_EN.md
index f6878f0937322..99c96e3961490 100644
--- a/solution/0000-0099/0002.Add Two Numbers/README_EN.md
+++ b/solution/0000-0099/0002.Add Two Numbers/README_EN.md
@@ -143,9 +143,9 @@ class Solution {
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
- ListNode* dummy = new ListNode();
+ ListNode dummy;
int carry = 0;
- ListNode* cur = dummy;
+ ListNode* cur = &dummy;
while (l1 || l2 || carry) {
int s = (l1 ? l1->val : 0) + (l2 ? l2->val : 0) + carry;
carry = s / 10;
@@ -154,7 +154,7 @@ public:
l1 = l1 ? l1->next : nullptr;
l2 = l2 ? l2->next : nullptr;
}
- return dummy->next;
+ return dummy.next;
}
};
```
@@ -490,6 +490,52 @@ proc addTwoNumbers(l1: var SinglyLinkedList, l2: var SinglyLinkedList): SinglyLi
result = aggregate
```
+#### C
+
+```c
+
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * struct ListNode *next;
+ * };
+ */
+
+struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
+ struct ListNode* dummy = (struct ListNode*) malloc(sizeof(struct ListNode));
+ dummy->val = 0;
+ dummy->next = NULL;
+ struct ListNode* curr = dummy;
+ int carry = 0;
+
+ while (l1 != NULL || l2 != NULL || carry != 0) {
+ int sum = carry;
+ if (l1 != NULL) {
+ sum += l1->val;
+ l1 = l1->next;
+ }
+ if (l2 != NULL) {
+ sum += l2->val;
+ l2 = l2->next;
+ }
+
+ carry = sum / 10;
+ int val = sum % 10;
+
+ struct ListNode* newNode = (struct ListNode*) malloc(sizeof(struct ListNode));
+ newNode->val = val;
+ newNode->next = NULL;
+ curr->next = newNode;
+ curr = curr->next;
+ }
+
+ struct ListNode* result = dummy->next;
+ free(dummy);
+ return result;
+}
+```
+
diff --git a/solution/0000-0099/0002.Add Two Numbers/Solution.c b/solution/0000-0099/0002.Add Two Numbers/Solution.c
new file mode 100644
index 0000000000000..0ca00b4bd6752
--- /dev/null
+++ b/solution/0000-0099/0002.Add Two Numbers/Solution.c
@@ -0,0 +1,41 @@
+
+/**
+ * Definition for singly-linked list.
+ * struct ListNode {
+ * int val;
+ * struct ListNode *next;
+ * };
+ */
+
+struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
+ struct ListNode* dummy = (struct ListNode*) malloc(sizeof(struct ListNode));
+ dummy->val = 0;
+ dummy->next = NULL;
+ struct ListNode* curr = dummy;
+ int carry = 0;
+
+ while (l1 != NULL || l2 != NULL || carry != 0) {
+ int sum = carry;
+ if (l1 != NULL) {
+ sum += l1->val;
+ l1 = l1->next;
+ }
+ if (l2 != NULL) {
+ sum += l2->val;
+ l2 = l2->next;
+ }
+
+ carry = sum / 10;
+ int val = sum % 10;
+
+ struct ListNode* newNode = (struct ListNode*) malloc(sizeof(struct ListNode));
+ newNode->val = val;
+ newNode->next = NULL;
+ curr->next = newNode;
+ curr = curr->next;
+ }
+
+ struct ListNode* result = dummy->next;
+ free(dummy);
+ return result;
+}
diff --git a/solution/0000-0099/0002.Add Two Numbers/Solution.cpp b/solution/0000-0099/0002.Add Two Numbers/Solution.cpp
index b06a8b66b90b4..0d1b36d111994 100644
--- a/solution/0000-0099/0002.Add Two Numbers/Solution.cpp
+++ b/solution/0000-0099/0002.Add Two Numbers/Solution.cpp
@@ -11,9 +11,9 @@
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
- ListNode* dummy = new ListNode();
+ ListNode dummy;
int carry = 0;
- ListNode* cur = dummy;
+ ListNode* cur = &dummy;
while (l1 || l2 || carry) {
int s = (l1 ? l1->val : 0) + (l2 ? l2->val : 0) + carry;
carry = s / 10;
@@ -22,6 +22,6 @@ class Solution {
l1 = l1 ? l1->next : nullptr;
l2 = l2 ? l2->next : nullptr;
}
- return dummy->next;
+ return dummy.next;
}
};
\ No newline at end of file
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md
index 0a34e8470465a..d95ea8a5d77a9 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md
@@ -62,26 +62,15 @@ tags:
-### 方法一:双指针 + 哈希表
+### 方法一:滑动窗口
-定义一个哈希表记录当前窗口内出现的字符,记 $i$ 和 $j$ 分别表示不重复子串的开始位置和结束位置,无重复字符子串的最大长度记为 `ans`。
+我们可以用两个指针 $l$ 和 $r$ 维护一个滑动窗口,使其始终满足窗口内没有重复字符,初始时 $l$ 和 $r$ 都指向字符串的第一个字符。用一个哈希表或者长度为 $128$ 的数组 $\textit{cnt}$ 来记录每个字符出现的次数,其中 $\textit{cnt}[c]$ 表示字符 $c$ 出现的次数。
-遍历字符串 `s` 的每个字符 $s[j]$,我们记为 $c$。若 $s[i..j-1]$ 窗口内存在 $c$,则 $i$ 循环向右移动,更新哈希表,直至 $s[i..j-1]$ 窗口不存在 `c`,循环结束。将 `c` 加入哈希表中,此时 $s[i..j]$ 窗口内不含重复元素,更新 `ans` 的最大值。
+接下来,我们依次移动右指针 $r$,每次移动时,将 $\textit{cnt}[s[r]]$ 的值加 $1$,然后判断当前窗口 $[l, r]$ 内 $\textit{cnt}[s[r]]$ 是否大于 $1$,如果大于 $1$,说明当前窗口内有重复字符,我们需要移动左指针 $l$,直到窗口内没有重复字符为止。然后,我们更新答案 $\textit{ans} = \max(\textit{ans}, r - l + 1)$。
-最后返回 `ans` 即可。
+最终,我们返回答案 $\textit{ans}$ 即可。
-时间复杂度 $O(n)$,其中 $n$ 表示字符串 `s` 的长度。
-
-双指针算法模板:
-
-```java
-for (int i = 0, j = 0; i < n; ++i) {
- while (j < i && check(j, i)) {
- ++j;
- }
- // 具体问题的逻辑
-}
-```
+时间复杂度 $O(n)$,其中 $n$ 为字符串的长度。空间复杂度 $O(|\Sigma|)$,其中 $\Sigma$ 表示字符集,这里 $\Sigma$ 的大小为 $128$。
@@ -90,14 +79,14 @@ for (int i = 0, j = 0; i < n; ++i) {
```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
- ss = set()
- ans = i = 0
- for j, c in enumerate(s):
- while c in ss:
- ss.remove(s[i])
- i += 1
- ss.add(c)
- ans = max(ans, j - i + 1)
+ cnt = Counter()
+ ans = l = 0
+ for r, c in enumerate(s):
+ cnt[c] += 1
+ while cnt[c] > 1:
+ cnt[s[l]] -= 1
+ l += 1
+ ans = max(ans, r - l + 1)
return ans
```
@@ -106,15 +95,15 @@ class Solution:
```java
class Solution {
public int lengthOfLongestSubstring(String s) {
- boolean[] ss = new boolean[128];
- int ans = 0;
- for (int i = 0, j = 0; j < s.length(); ++j) {
- char c = s.charAt(j);
- while (ss[c]) {
- ss[s.charAt(i++)] = false;
+ int[] cnt = new int[128];
+ int ans = 0, n = s.length();
+ for (int l = 0, r = 0; r < n; ++r) {
+ char c = s.charAt(r);
+ ++cnt[c];
+ while (cnt[c] > 1) {
+ --cnt[s.charAt(l++)];
}
- ss[c] = true;
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
}
@@ -127,14 +116,14 @@ class Solution {
class Solution {
public:
int lengthOfLongestSubstring(string s) {
- bool ss[128]{};
- int ans = 0;
- for (int i = 0, j = 0; j < s.size(); ++j) {
- while (ss[s[j]]) {
- ss[s[i++]] = false;
+ int cnt[128]{};
+ int ans = 0, n = s.size();
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss[s[j]] = true;
- ans = max(ans, j - i + 1);
+ ans = max(ans, r - l + 1);
}
return ans;
}
@@ -145,14 +134,15 @@ public:
```go
func lengthOfLongestSubstring(s string) (ans int) {
- ss := [128]bool{}
- for i, j := 0, 0; j < len(s); j++ {
- for ss[s[j]] {
- ss[s[i]] = false
- i++
+ cnt := [128]int{}
+ l := 0
+ for r, c := range s {
+ cnt[c]++
+ for cnt[c] > 1 {
+ cnt[s[l]]--
+ l++
}
- ss[s[j]] = true
- ans = max(ans, j-i+1)
+ ans = max(ans, r-l+1)
}
return
}
@@ -163,13 +153,15 @@ func lengthOfLongestSubstring(s string) (ans int) {
```ts
function lengthOfLongestSubstring(s: string): number {
let ans = 0;
- const ss: Set = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const cnt = new Map();
+ const n = s.length;
+ for (let l = 0, r = 0; r < n; ++r) {
+ cnt.set(s[r], (cnt.get(s[r]) || 0) + 1);
+ while (cnt.get(s[r])! > 1) {
+ cnt.set(s[l], cnt.get(s[l])! - 1);
+ ++l;
}
- ss.add(s[j]);
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
}
@@ -178,24 +170,22 @@ function lengthOfLongestSubstring(s: string): number {
#### Rust
```rust
-use std::collections::HashSet;
-
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
- let s = s.as_bytes();
- let mut ss = HashSet::new();
- let mut i = 0;
- s.iter()
- .map(|c| {
- while ss.contains(&c) {
- ss.remove(&s[i]);
- i += 1;
- }
- ss.insert(c);
- ss.len()
- })
- .max()
- .unwrap_or(0) as i32
+ let mut cnt = [0; 128];
+ let mut ans = 0;
+ let mut l = 0;
+ let chars: Vec = s.chars().collect();
+ let n = chars.len();
+ for (r, &c) in chars.iter().enumerate() {
+ cnt[c as usize] += 1;
+ while cnt[c as usize] > 1 {
+ cnt[chars[l] as usize] -= 1;
+ l += 1;
+ }
+ ans = ans.max((r - l + 1) as i32);
+ }
+ ans
}
}
```
@@ -209,13 +199,15 @@ impl Solution {
*/
var lengthOfLongestSubstring = function (s) {
let ans = 0;
- const ss = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const n = s.length;
+ const cnt = new Map();
+ for (let l = 0, r = 0; r < n; ++r) {
+ cnt.set(s[r], (cnt.get(s[r]) || 0) + 1);
+ while (cnt.get(s[r]) > 1) {
+ cnt.set(s[l], cnt.get(s[l]) - 1);
+ ++l;
}
- ss.add(s[j]);
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
};
@@ -226,14 +218,15 @@ var lengthOfLongestSubstring = function (s) {
```cs
public class Solution {
public int LengthOfLongestSubstring(string s) {
+ int n = s.Length;
int ans = 0;
- var ss = new HashSet();
- for (int i = 0, j = 0; j < s.Length; ++j) {
- while (ss.Contains(s[j])) {
- ss.Remove(s[i++]);
+ var cnt = new int[128];
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss.Add(s[j]);
- ans = Math.Max(ans, j - i + 1);
+ ans = Math.Max(ans, r - l + 1);
}
return ans;
}
@@ -244,19 +237,18 @@ public class Solution {
```php
class Solution {
- /**
- * @param String $s
- * @return Integer
- */
function lengthOfLongestSubstring($s) {
+ $n = strlen($s);
$ans = 0;
- $ss = [];
- for ($i = 0, $j = 0; $j < strlen($s); ++$j) {
- while (in_array($s[$j], $ss)) {
- unset($ss[array_search($s[$i++], $ss)]);
+ $cnt = array_fill(0, 128, 0);
+ $l = 0;
+ for ($r = 0; $r < $n; ++$r) {
+ $cnt[ord($s[$r])]++;
+ while ($cnt[ord($s[$r])] > 1) {
+ $cnt[ord($s[$l])]--;
+ $l++;
}
- $ss[] = $s[$j];
- $ans = max($ans, $j - $i + 1);
+ $ans = max($ans, $r - $l + 1);
}
return $ans;
}
@@ -268,68 +260,73 @@ class Solution {
```swift
class Solution {
func lengthOfLongestSubstring(_ s: String) -> Int {
- var map = [Character: Int]()
- var currentStartingIndex = 0
- var i = 0
- var maxLength = 0
- for char in s {
- if map[char] != nil {
- if map[char]! >= currentStartingIndex {
- maxLength = max(maxLength, i - currentStartingIndex)
- currentStartingIndex = map[char]! + 1
- }
+ let n = s.count
+ var ans = 0
+ var cnt = [Int](repeating: 0, count: 128)
+ var l = 0
+ let sArray = Array(s)
+ for r in 0.. 1 {
+ cnt[Int(sArray[l].asciiValue!)] -= 1
+ l += 1
}
- map[char] = i
- i += 1
+ ans = max(ans, r - l + 1)
}
- return max(maxLength, i - currentStartingIndex)
+ return ans
}
}
```
-#### Nim
-
-```nim
-proc lengthOfLongestSubstring(s: string): int =
- var
- i = 0
- j = 0
- res = 0
- literals: set[char] = {}
-
- while i < s.len:
- while s[i] in literals:
- if s[j] in literals:
- excl(literals, s[j])
- j += 1
- literals.incl(s[i]) # Uniform Function Call Syntax f(x) = x.f
- res = max(res, i - j + 1)
- i += 1
-
- result = res # result has the default return value
-```
-
#### Kotlin
```kotlin
class Solution {
fun lengthOfLongestSubstring(s: String): Int {
- var char_set = BooleanArray(128)
- var left = 0
+ val n = s.length
var ans = 0
- s.forEachIndexed { right, c ->
- while (char_set[c.code]) {
- char_set[s[left].code] = false
- left++
+ val cnt = IntArray(128)
+ var l = 0
+ for (r in 0 until n) {
+ cnt[s[r].toInt()]++
+ while (cnt[s[r].toInt()] > 1) {
+ cnt[s[l].toInt()]--
+ l++
}
- char_set[c.code] = true
- ans = Math.max(ans, right - left + 1)
+ ans = Math.max(ans, r - l + 1)
}
return ans
}
}
```
+#### C
+
+```c
+int lengthOfLongestSubstring(char* s) {
+ int freq[256] = {0};
+ int l = 0, r = 0;
+ int ans = 0;
+ int len = strlen(s);
+
+ for (r = 0; r < len; r++) {
+ char c = s[r];
+ freq[(unsigned char) c]++;
+
+ while (freq[(unsigned char) c] > 1) {
+ freq[(unsigned char) s[l]]--;
+ l++;
+ }
+
+ if (ans < r - l + 1) {
+ ans = r - l + 1;
+ }
+ }
+
+ return ans;
+}
+```
+
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md
index 7218d6526623c..16624fcc16b80 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md
@@ -18,7 +18,7 @@ tags:
-Given a string s
, find the length of the longest substring without repeating characters.
+Given a string s
, find the length of the longest substring without duplicate characters.
Example 1:
@@ -60,26 +60,15 @@ Notice that the answer must be a substring, "pwke" is a subsequence an
-### Solution 1: Two pointers + Hash Table
+### Solution 1: Sliding Window
-Define a hash table to record the characters in the current window. Let $i$ and $j$ represent the start and end positions of the non-repeating substring, respectively. The length of the longest non-repeating substring is recorded by `ans`.
+We can use two pointers $l$ and $r$ to maintain a sliding window that always satisfies the condition of having no repeating characters within the window. Initially, both $l$ and $r$ point to the first character of the string. We use a hash table or an array of length $128$ called $\textit{cnt}$ to record the number of occurrences of each character, where $\textit{cnt}[c]$ represents the number of occurrences of character $c$.
-For each character $s[j]$ in the string `s`, we call it $c$. If $c$ exists in the window $s[i..j-1]$, we move $i$ to the right until $s[i..j-1]$ does not contain `c`. Then we add `c` to the hash table. At this time, the window $s[i..j]$ does not contain repeated elements, and we update the maximum value of `ans`.
+Next, we move the right pointer $r$ one step at a time. Each time we move it, we increment the value of $\textit{cnt}[s[r]]$ by $1$, and then check if the value of $\textit{cnt}[s[r]]$ is greater than $1$ within the current window $[l, r]$. If it is greater than $1$, it means there are repeating characters within the current window, and we need to move the left pointer $l$ until there are no repeating characters within the window. Then, we update the answer $\textit{ans} = \max(\textit{ans}, r - l + 1)$.
-Finally, return `ans`.
+Finally, we return the answer $\textit{ans}$.
-The time complexity is $O(n)$, where $n$ represents the length of the string `s`.
-
-Two pointers algorithm template:
-
-```java
-for (int i = 0, j = 0; i < n; ++i) {
- while (j < i && check(j, i)) {
- ++j;
- }
- // logic of specific problem
-}
-```
+The time complexity is $O(n)$, where $n$ is the length of the string. The space complexity is $O(|\Sigma|)$, where $\Sigma$ represents the character set, and the size of $\Sigma$ is $128$.
@@ -88,14 +77,14 @@ for (int i = 0, j = 0; i < n; ++i) {
```python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
- ss = set()
- ans = i = 0
- for j, c in enumerate(s):
- while c in ss:
- ss.remove(s[i])
- i += 1
- ss.add(c)
- ans = max(ans, j - i + 1)
+ cnt = Counter()
+ ans = l = 0
+ for r, c in enumerate(s):
+ cnt[c] += 1
+ while cnt[c] > 1:
+ cnt[s[l]] -= 1
+ l += 1
+ ans = max(ans, r - l + 1)
return ans
```
@@ -104,15 +93,15 @@ class Solution:
```java
class Solution {
public int lengthOfLongestSubstring(String s) {
- boolean[] ss = new boolean[128];
- int ans = 0;
- for (int i = 0, j = 0; j < s.length(); ++j) {
- char c = s.charAt(j);
- while (ss[c]) {
- ss[s.charAt(i++)] = false;
+ int[] cnt = new int[128];
+ int ans = 0, n = s.length();
+ for (int l = 0, r = 0; r < n; ++r) {
+ char c = s.charAt(r);
+ ++cnt[c];
+ while (cnt[c] > 1) {
+ --cnt[s.charAt(l++)];
}
- ss[c] = true;
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
}
@@ -125,14 +114,14 @@ class Solution {
class Solution {
public:
int lengthOfLongestSubstring(string s) {
- bool ss[128]{};
- int ans = 0;
- for (int i = 0, j = 0; j < s.size(); ++j) {
- while (ss[s[j]]) {
- ss[s[i++]] = false;
+ int cnt[128]{};
+ int ans = 0, n = s.size();
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss[s[j]] = true;
- ans = max(ans, j - i + 1);
+ ans = max(ans, r - l + 1);
}
return ans;
}
@@ -143,14 +132,15 @@ public:
```go
func lengthOfLongestSubstring(s string) (ans int) {
- ss := [128]bool{}
- for i, j := 0, 0; j < len(s); j++ {
- for ss[s[j]] {
- ss[s[i]] = false
- i++
+ cnt := [128]int{}
+ l := 0
+ for r, c := range s {
+ cnt[c]++
+ for cnt[c] > 1 {
+ cnt[s[l]]--
+ l++
}
- ss[s[j]] = true
- ans = max(ans, j-i+1)
+ ans = max(ans, r-l+1)
}
return
}
@@ -161,13 +151,15 @@ func lengthOfLongestSubstring(s string) (ans int) {
```ts
function lengthOfLongestSubstring(s: string): number {
let ans = 0;
- const ss: Set = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const cnt = new Map();
+ const n = s.length;
+ for (let l = 0, r = 0; r < n; ++r) {
+ cnt.set(s[r], (cnt.get(s[r]) || 0) + 1);
+ while (cnt.get(s[r])! > 1) {
+ cnt.set(s[l], cnt.get(s[l])! - 1);
+ ++l;
}
- ss.add(s[j]);
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
}
@@ -176,24 +168,22 @@ function lengthOfLongestSubstring(s: string): number {
#### Rust
```rust
-use std::collections::HashSet;
-
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
- let s = s.as_bytes();
- let mut ss = HashSet::new();
- let mut i = 0;
- s.iter()
- .map(|c| {
- while ss.contains(&c) {
- ss.remove(&s[i]);
- i += 1;
- }
- ss.insert(c);
- ss.len()
- })
- .max()
- .unwrap_or(0) as i32
+ let mut cnt = [0; 128];
+ let mut ans = 0;
+ let mut l = 0;
+ let chars: Vec = s.chars().collect();
+ let n = chars.len();
+ for (r, &c) in chars.iter().enumerate() {
+ cnt[c as usize] += 1;
+ while cnt[c as usize] > 1 {
+ cnt[chars[l] as usize] -= 1;
+ l += 1;
+ }
+ ans = ans.max((r - l + 1) as i32);
+ }
+ ans
}
}
```
@@ -207,13 +197,15 @@ impl Solution {
*/
var lengthOfLongestSubstring = function (s) {
let ans = 0;
- const ss = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const n = s.length;
+ const cnt = new Map();
+ for (let l = 0, r = 0; r < n; ++r) {
+ cnt.set(s[r], (cnt.get(s[r]) || 0) + 1);
+ while (cnt.get(s[r]) > 1) {
+ cnt.set(s[l], cnt.get(s[l]) - 1);
+ ++l;
}
- ss.add(s[j]);
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
};
@@ -224,14 +216,15 @@ var lengthOfLongestSubstring = function (s) {
```cs
public class Solution {
public int LengthOfLongestSubstring(string s) {
+ int n = s.Length;
int ans = 0;
- var ss = new HashSet();
- for (int i = 0, j = 0; j < s.Length; ++j) {
- while (ss.Contains(s[j])) {
- ss.Remove(s[i++]);
+ var cnt = new int[128];
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss.Add(s[j]);
- ans = Math.Max(ans, j - i + 1);
+ ans = Math.Max(ans, r - l + 1);
}
return ans;
}
@@ -242,19 +235,18 @@ public class Solution {
```php
class Solution {
- /**
- * @param String $s
- * @return Integer
- */
function lengthOfLongestSubstring($s) {
+ $n = strlen($s);
$ans = 0;
- $ss = [];
- for ($i = 0, $j = 0; $j < strlen($s); ++$j) {
- while (in_array($s[$j], $ss)) {
- unset($ss[array_search($s[$i++], $ss)]);
+ $cnt = array_fill(0, 128, 0);
+ $l = 0;
+ for ($r = 0; $r < $n; ++$r) {
+ $cnt[ord($s[$r])]++;
+ while ($cnt[ord($s[$r])] > 1) {
+ $cnt[ord($s[$l])]--;
+ $l++;
}
- $ss[] = $s[$j];
- $ans = max($ans, $j - $i + 1);
+ $ans = max($ans, $r - $l + 1);
}
return $ans;
}
@@ -266,68 +258,73 @@ class Solution {
```swift
class Solution {
func lengthOfLongestSubstring(_ s: String) -> Int {
- var map = [Character: Int]()
- var currentStartingIndex = 0
- var i = 0
- var maxLength = 0
- for char in s {
- if map[char] != nil {
- if map[char]! >= currentStartingIndex {
- maxLength = max(maxLength, i - currentStartingIndex)
- currentStartingIndex = map[char]! + 1
- }
+ let n = s.count
+ var ans = 0
+ var cnt = [Int](repeating: 0, count: 128)
+ var l = 0
+ let sArray = Array(s)
+ for r in 0.. 1 {
+ cnt[Int(sArray[l].asciiValue!)] -= 1
+ l += 1
}
- map[char] = i
- i += 1
+ ans = max(ans, r - l + 1)
}
- return max(maxLength, i - currentStartingIndex)
+ return ans
}
}
```
-#### Nim
-
-```nim
-proc lengthOfLongestSubstring(s: string): int =
- var
- i = 0
- j = 0
- res = 0
- literals: set[char] = {}
-
- while i < s.len:
- while s[i] in literals:
- if s[j] in literals:
- excl(literals, s[j])
- j += 1
- literals.incl(s[i]) # Uniform Function Call Syntax f(x) = x.f
- res = max(res, i - j + 1)
- i += 1
-
- result = res # result has the default return value
-```
-
#### Kotlin
```kotlin
class Solution {
fun lengthOfLongestSubstring(s: String): Int {
- var char_set = BooleanArray(128)
- var left = 0
+ val n = s.length
var ans = 0
- s.forEachIndexed { right, c ->
- while (char_set[c.code]) {
- char_set[s[left].code] = false
- left++
+ val cnt = IntArray(128)
+ var l = 0
+ for (r in 0 until n) {
+ cnt[s[r].toInt()]++
+ while (cnt[s[r].toInt()] > 1) {
+ cnt[s[l].toInt()]--
+ l++
}
- char_set[c.code] = true
- ans = Math.max(ans, right - left + 1)
+ ans = Math.max(ans, r - l + 1)
}
return ans
}
}
```
+#### C
+
+```c
+int lengthOfLongestSubstring(char* s) {
+ int freq[256] = {0};
+ int l = 0, r = 0;
+ int ans = 0;
+ int len = strlen(s);
+
+ for (r = 0; r < len; r++) {
+ char c = s[r];
+ freq[(unsigned char) c]++;
+
+ while (freq[(unsigned char) c] > 1) {
+ freq[(unsigned char) s[l]]--;
+ l++;
+ }
+
+ if (ans < r - l + 1) {
+ ans = r - l + 1;
+ }
+ }
+
+ return ans;
+}
+```
+
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.c b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.c
new file mode 100644
index 0000000000000..673e098af92ac
--- /dev/null
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.c
@@ -0,0 +1,22 @@
+int lengthOfLongestSubstring(char* s) {
+ int freq[256] = {0};
+ int l = 0, r = 0;
+ int ans = 0;
+ int len = strlen(s);
+
+ for (r = 0; r < len; r++) {
+ char c = s[r];
+ freq[(unsigned char) c]++;
+
+ while (freq[(unsigned char) c] > 1) {
+ freq[(unsigned char) s[l]]--;
+ l++;
+ }
+
+ if (ans < r - l + 1) {
+ ans = r - l + 1;
+ }
+ }
+
+ return ans;
+}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cpp b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cpp
index 980f98df2cc44..549f59f0ae8b7 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cpp
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cpp
@@ -1,15 +1,15 @@
class Solution {
public:
int lengthOfLongestSubstring(string s) {
- bool ss[128]{};
- int ans = 0;
- for (int i = 0, j = 0; j < s.size(); ++j) {
- while (ss[s[j]]) {
- ss[s[i++]] = false;
+ int cnt[128]{};
+ int ans = 0, n = s.size();
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss[s[j]] = true;
- ans = max(ans, j - i + 1);
+ ans = max(ans, r - l + 1);
}
return ans;
}
-};
\ No newline at end of file
+};
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cs b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cs
index 2c29e34899025..044baded41e3a 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cs
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.cs
@@ -1,13 +1,14 @@
public class Solution {
public int LengthOfLongestSubstring(string s) {
+ int n = s.Length;
int ans = 0;
- var ss = new HashSet();
- for (int i = 0, j = 0; j < s.Length; ++j) {
- while (ss.Contains(s[j])) {
- ss.Remove(s[i++]);
+ var cnt = new int[128];
+ for (int l = 0, r = 0; r < n; ++r) {
+ ++cnt[s[r]];
+ while (cnt[s[r]] > 1) {
+ --cnt[s[l++]];
}
- ss.Add(s[j]);
- ans = Math.Max(ans, j - i + 1);
+ ans = Math.Max(ans, r - l + 1);
}
return ans;
}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.go b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.go
index 68104afd448ff..365301a1ce97f 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.go
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.go
@@ -1,12 +1,13 @@
func lengthOfLongestSubstring(s string) (ans int) {
- ss := [128]bool{}
- for i, j := 0, 0; j < len(s); j++ {
- for ss[s[j]] {
- ss[s[i]] = false
- i++
+ cnt := [128]int{}
+ l := 0
+ for r, c := range s {
+ cnt[c]++
+ for cnt[c] > 1 {
+ cnt[s[l]]--
+ l++
}
- ss[s[j]] = true
- ans = max(ans, j-i+1)
+ ans = max(ans, r-l+1)
}
return
-}
\ No newline at end of file
+}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.java b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.java
index 28dda65b2442d..574f3c62a27e8 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.java
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.java
@@ -1,15 +1,15 @@
class Solution {
public int lengthOfLongestSubstring(String s) {
- boolean[] ss = new boolean[128];
- int ans = 0;
- for (int i = 0, j = 0; j < s.length(); ++j) {
- char c = s.charAt(j);
- while (ss[c]) {
- ss[s.charAt(i++)] = false;
+ int[] cnt = new int[128];
+ int ans = 0, n = s.length();
+ for (int l = 0, r = 0; r < n; ++r) {
+ char c = s.charAt(r);
+ ++cnt[c];
+ while (cnt[c] > 1) {
+ --cnt[s.charAt(l++)];
}
- ss[c] = true;
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
}
-}
\ No newline at end of file
+}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.js b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.js
index d87d290b2cfb3..16f64428d105f 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.js
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.js
@@ -4,13 +4,15 @@
*/
var lengthOfLongestSubstring = function (s) {
let ans = 0;
- const ss = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const n = s.length;
+ const cnt = new Map();
+ for (let l = 0, r = 0; r < n; ++r) {
+ cnt.set(s[r], (cnt.get(s[r]) || 0) + 1);
+ while (cnt.get(s[r]) > 1) {
+ cnt.set(s[l], cnt.get(s[l]) - 1);
+ ++l;
}
- ss.add(s[j]);
- ans = Math.max(ans, j - i + 1);
+ ans = Math.max(ans, r - l + 1);
}
return ans;
};
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.kt b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.kt
index f98e101a2f826..82cba82a59d3e 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.kt
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.kt
@@ -1,15 +1,16 @@
class Solution {
fun lengthOfLongestSubstring(s: String): Int {
- var char_set = BooleanArray(128)
- var left = 0
+ val n = s.length
var ans = 0
- s.forEachIndexed { right, c ->
- while (char_set[c.code]) {
- char_set[s[left].code] = false
- left++
+ val cnt = IntArray(128)
+ var l = 0
+ for (r in 0 until n) {
+ cnt[s[r].toInt()]++
+ while (cnt[s[r].toInt()] > 1) {
+ cnt[s[l].toInt()]--
+ l++
}
- char_set[c.code] = true
- ans = Math.max(ans, right - left + 1)
+ ans = Math.max(ans, r - l + 1)
}
return ans
}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.nim b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.nim
deleted file mode 100644
index 1275a35bfbee6..0000000000000
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.nim
+++ /dev/null
@@ -1,17 +0,0 @@
-proc lengthOfLongestSubstring(s: string): int =
- var
- i = 0
- j = 0
- res = 0
- literals: set[char] = {}
-
- while i < s.len:
- while s[i] in literals:
- if s[j] in literals:
- excl(literals, s[j])
- j += 1
- literals.incl(s[i]) # Uniform Function Call Syntax f(x) = x.f
- res = max(res, i - j + 1)
- i += 1
-
- result = res # result has the default return value
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.php b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.php
index d51d37abe0e51..af9ebc954a1d7 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.php
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.php
@@ -1,18 +1,17 @@
class Solution {
- /**
- * @param String $s
- * @return Integer
- */
function lengthOfLongestSubstring($s) {
+ $n = strlen($s);
$ans = 0;
- $ss = [];
- for ($i = 0, $j = 0; $j < strlen($s); ++$j) {
- while (in_array($s[$j], $ss)) {
- unset($ss[array_search($s[$i++], $ss)]);
+ $cnt = array_fill(0, 128, 0);
+ $l = 0;
+ for ($r = 0; $r < $n; ++$r) {
+ $cnt[ord($s[$r])]++;
+ while ($cnt[ord($s[$r])] > 1) {
+ $cnt[ord($s[$l])]--;
+ $l++;
}
- $ss[] = $s[$j];
- $ans = max($ans, $j - $i + 1);
+ $ans = max($ans, $r - $l + 1);
}
return $ans;
}
-}
\ No newline at end of file
+}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.py b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.py
index 752e44282faee..828f12c0e90c7 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.py
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.py
@@ -1,11 +1,11 @@
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
- ss = set()
- ans = i = 0
- for j, c in enumerate(s):
- while c in ss:
- ss.remove(s[i])
- i += 1
- ss.add(c)
- ans = max(ans, j - i + 1)
+ cnt = Counter()
+ ans = l = 0
+ for r, c in enumerate(s):
+ cnt[c] += 1
+ while cnt[c] > 1:
+ cnt[s[l]] -= 1
+ l += 1
+ ans = max(ans, r - l + 1)
return ans
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.rs b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.rs
index 64e43f86096f5..ca4557f31fda6 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.rs
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.rs
@@ -1,20 +1,18 @@
-use std::collections::HashSet;
-
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
- let s = s.as_bytes();
- let mut ss = HashSet::new();
- let mut i = 0;
- s.iter()
- .map(|c| {
- while ss.contains(&c) {
- ss.remove(&s[i]);
- i += 1;
- }
- ss.insert(c);
- ss.len()
- })
- .max()
- .unwrap_or(0) as i32
+ let mut cnt = [0; 128];
+ let mut ans = 0;
+ let mut l = 0;
+ let chars: Vec = s.chars().collect();
+ let n = chars.len();
+ for (r, &c) in chars.iter().enumerate() {
+ cnt[c as usize] += 1;
+ while cnt[c as usize] > 1 {
+ cnt[chars[l] as usize] -= 1;
+ l += 1;
+ }
+ ans = ans.max((r - l + 1) as i32);
+ }
+ ans
}
}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.swift b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.swift
index 02462178bdfd5..672a8f0f20787 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.swift
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.swift
@@ -1,19 +1,18 @@
class Solution {
func lengthOfLongestSubstring(_ s: String) -> Int {
- var map = [Character: Int]()
- var currentStartingIndex = 0
- var i = 0
- var maxLength = 0
- for char in s {
- if map[char] != nil {
- if map[char]! >= currentStartingIndex {
- maxLength = max(maxLength, i - currentStartingIndex)
- currentStartingIndex = map[char]! + 1
- }
+ let n = s.count
+ var ans = 0
+ var cnt = [Int](repeating: 0, count: 128)
+ var l = 0
+ let sArray = Array(s)
+ for r in 0.. 1 {
+ cnt[Int(sArray[l].asciiValue!)] -= 1
+ l += 1
}
- map[char] = i
- i += 1
+ ans = max(ans, r - l + 1)
}
- return max(maxLength, i - currentStartingIndex)
+ return ans
}
}
diff --git a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.ts b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.ts
index 6f4d8610c0bb0..f37a5ffaa95b6 100644
--- a/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.ts
+++ b/solution/0000-0099/0003.Longest Substring Without Repeating Characters/Solution.ts
@@ -1,12 +1,14 @@
function lengthOfLongestSubstring(s: string): number {
let ans = 0;
- const ss: Set = new Set();
- for (let i = 0, j = 0; j < s.length; ++j) {
- while (ss.has(s[j])) {
- ss.delete(s[i++]);
+ const cnt = new Map