Skip to content

[pull] main from doocs:main #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 27 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: deploy

on:
workflow_dispatch:
push:
branches:
- main
Expand All @@ -12,22 +13,14 @@ on:
- lcof/**
- lcci/**
- basic/**
workflow_dispatch:

env:
MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }}

permissions:
contents: write

concurrency:
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
Expand Down Expand Up @@ -62,36 +55,36 @@ jobs:
python3 -m pip install -r requirements.txt
python3 -m pip install "mkdocs-material[imaging]"
sudo apt-get install pngquant

- name: Set MKDOCS_API_KEYS environment variable
run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV

- run: |
python3 main.py
mkdocs build -f mkdocs.yml
mkdocs build -f mkdocs-en.yml

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
cname: leetcode.doocs.org
- name: Generate CNAME file
run: echo "leetcode.doocs.org" > ./site/CNAME

# 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: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site

# - 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
# Deployment job
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github_pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
34 changes: 32 additions & 2 deletions solution/1300-1399/1399.Count Largest Group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ tags:

最后返回 $ans$ 即可。

时间复杂度 $O(n \times \log M)$,空间复杂度 $(\log M)$。其中 $n$ 为给定的数字,而 $M$ 是 $n$ 的数字范围
时间复杂度 $O(n \times \log n)$,空间复杂度 $(\log n)$。其中 $n$ 为给定的数字。

<!-- tabs:start -->

Expand Down Expand Up @@ -177,7 +177,7 @@ func countLargestGroup(n int) (ans int) {

```ts
function countLargestGroup(n: number): number {
const cnt: number[] = new Array(40).fill(0);
const cnt: number[] = Array(40).fill(0);
let mx = 0;
let ans = 0;
for (let i = 1; i <= n; ++i) {
Expand All @@ -197,6 +197,36 @@ function countLargestGroup(n: number): number {
}
```

#### Rust

```rust
impl Solution {
pub fn count_largest_group(n: i32) -> i32 {
let mut cnt = vec![0; 40];
let mut ans = 0;
let mut mx = 0;

for i in 1..=n {
let mut s = 0;
let mut x = i;
while x > 0 {
s += x % 10;
x /= 10;
}
cnt[s as usize] += 1;
if mx < cnt[s as usize] {
mx = cnt[s as usize];
ans = 1;
} else if mx == cnt[s as usize] {
ans += 1;
}
}

ans
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
34 changes: 32 additions & 2 deletions solution/1300-1399/1399.Count Largest Group/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ We enumerate each number in $[1,..n]$, calculate its sum of digits $s$, then inc

Finally, we return $ans$.

The time complexity is $O(n \times \log M)$, and the space complexity is $O(\log M)$. Where $n$ is the given number, and $M$ is the range of $n$.
The time complexity is $O(n \times \log n)$, and the space complexity is $O(\log n)$, where $n$ is the given number.

<!-- tabs:start -->

Expand Down Expand Up @@ -168,7 +168,7 @@ func countLargestGroup(n int) (ans int) {

```ts
function countLargestGroup(n: number): number {
const cnt: number[] = new Array(40).fill(0);
const cnt: number[] = Array(40).fill(0);
let mx = 0;
let ans = 0;
for (let i = 1; i <= n; ++i) {
Expand All @@ -188,6 +188,36 @@ function countLargestGroup(n: number): number {
}
```

#### Rust

```rust
impl Solution {
pub fn count_largest_group(n: i32) -> i32 {
let mut cnt = vec![0; 40];
let mut ans = 0;
let mut mx = 0;

for i in 1..=n {
let mut s = 0;
let mut x = i;
while x > 0 {
s += x % 10;
x /= 10;
}
cnt[s as usize] += 1;
if mx < cnt[s as usize] {
mx = cnt[s as usize];
ans = 1;
} else if mx == cnt[s as usize] {
ans += 1;
}
}

ans
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
25 changes: 25 additions & 0 deletions solution/1300-1399/1399.Count Largest Group/Solution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
impl Solution {
pub fn count_largest_group(n: i32) -> i32 {
let mut cnt = vec![0; 40];
let mut ans = 0;
let mut mx = 0;

for i in 1..=n {
let mut s = 0;
let mut x = i;
while x > 0 {
s += x % 10;
x /= 10;
}
cnt[s as usize] += 1;
if mx < cnt[s as usize] {
mx = cnt[s as usize];
ans = 1;
} else if mx == cnt[s as usize] {
ans += 1;
}
}

ans
}
}
2 changes: 1 addition & 1 deletion solution/1300-1399/1399.Count Largest Group/Solution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function countLargestGroup(n: number): number {
const cnt: number[] = new Array(40).fill(0);
const cnt: number[] = Array(40).fill(0);
let mx = 0;
let ans = 0;
for (let i = 1; i <= n; ++i) {
Expand Down