Skip to content

Commit 375d1d2

Browse files
authored
feat: add weekly contest 473 and biweekly contest 168 (#4798)
1 parent 07bf63c commit 375d1d2

File tree

73 files changed

+4277
-24
lines changed

Some content is hidden

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

73 files changed

+4277
-24
lines changed

solution/2000-2099/2043.Simple Bank System/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ bank.withdraw(10, 50); // 返回 false ,交易无效,因为账户 10 并
8282

8383
### 方法一:模拟
8484

85-
根据题意,我们可以使用一个数组 `balance` 来模拟银行账户的余额,数组下标从 0 开始,数组的值表示账户的余额
85+
我们可以使用一个数组 $\textit{balance}$ 来存储每个账户的余额。对于每个操作,我们只需要根据题目要求进行相应的判断和更新即可
8686

87-
- 初始化时,我们将 `balance` 数组赋给成员变量 `this.balance`,并将 `balance` 的长度赋给成员变量 `this.n`
88-
- `transfer` 函数中,如果 `account1``account2` 大于 `n``balance[account1 - 1]` 小于 `money`,则返回 `false`,否则,将 `balance[account1 - 1]` 减去 `money`,将 `balance[account2 - 1]` 加上 `money`,并返回 `true`
89-
- `deposit` 函数中,如果 `account` 大于 `n`,则返回 `false`,否则,将 `balance[account - 1]` 加上 `money`,并返回 `true`
90-
- `withdraw` 函数中,如果 `account` 大于 `n``balance[account - 1]` 小于 `money`,则返回 `false`,否则,将 `balance[account - 1]` 减去 `money`,并返回 `true`
87+
对于 $\textit{transfer}$ 操作,我们需要检查账户编号是否合法以及账户余额是否足够,如果满足条件则进行转账操作。
9188

92-
以上操作的时间复杂度均为 $O(1)$,空间复杂度为 $O(n)$。其中,$n$ 为 `balance` 的长度。
89+
对于 $\textit{deposit}$ 操作,我们只需要检查账户编号是否合法,然后进行存款操作。
90+
91+
对于 $\textit{withdraw}$ 操作,我们需要检查账户编号是否合法以及账户余额是否足够,如果满足条件则进行取款操作。
92+
93+
以上每个操作的时间复杂度均为 $O(1)$,因此整体时间复杂度为 $O(q)$,其中 $q$ 是操作次数。空间复杂度 $O(1)$。
9394

9495
<!-- tabs:start -->
9596

solution/2000-2099/2043.Simple Bank System/README_EN.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ bank.withdraw(10, 50); // return false, it is invalid because account 10 does
8080

8181
### Solution 1: Simulation
8282

83-
According to the problem description, we can use an array `balance` to simulate the balance of bank accounts. The array index starts from 0, and the value of the array represents the balance of the account.
83+
We can use an array $\textit{balance}$ to store the balance of each account. For each operation, we simply perform the required checks and updates according to the problem statement.
8484

85-
- During initialization, we assign the `balance` array to the member variable `this.balance`, and assign the length of `balance` to the member variable `this.n`.
86-
- In the `transfer` function, if `account1` or `account2` is greater than `n` or `balance[account1 - 1]` is less than `money`, return `false`. Otherwise, subtract `money` from `balance[account1 - 1]`, add `money` to `balance[account2 - 1]`, and return `true`.
87-
- In the `deposit` function, if `account` is greater than `n`, return `false`. Otherwise, add `money` to `balance[account - 1]`, and return `true`.
88-
- In the `withdraw` function, if `account` is greater than `n` or `balance[account - 1]` is less than `money`, return `false`. Otherwise, subtract `money` from `balance[account - 1]`, and return `true`.
85+
For the $\textit{transfer}$ operation, we need to check whether the account numbers are valid and whether the balance is sufficient. If the conditions are met, we perform the transfer.
8986

90-
The time complexity of the above operations is $O(1)$, and the space complexity is $O(n)$. Here, $n$ is the length of `balance`.
87+
For the $\textit{deposit}$ operation, we only need to check whether the account number is valid, and then perform the deposit.
88+
89+
For the $\textit{withdraw}$ operation, we need to check whether the account number is valid and whether the balance is sufficient. If the conditions are met, we perform the withdrawal.
90+
91+
Each operation has a time complexity of $O(1)$, so the overall time complexity is $O(q)$, where $q$ is the number of operations. The space complexity is $O(1)$.
9192

9293
<!-- tabs:start -->
9394

solution/2000-2099/2048.Next Greater Numerically Balanced Number/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tags:
3535
<strong>输出:</strong>22
3636
<strong>解释:</strong>
3737
22 是一个数值平衡数,因为:
38-
- 数字 2 出现 2 次
38+
- 数字 2 出现 2 次
3939
这也是严格大于 1 的最小数值平衡数。
4040
</pre>
4141

@@ -47,7 +47,7 @@ tags:
4747
<strong>解释:</strong>
4848
1333 是一个数值平衡数,因为:
4949
- 数字 1 出现 1 次。
50-
- 数字 3 出现 3 次。
50+
- 数字 3 出现 3 次。
5151
这也是严格大于 1000 的最小数值平衡数。
5252
注意,1022 不能作为本输入的答案,因为数字 0 的出现次数超过了 0 。</pre>
5353

@@ -59,7 +59,7 @@ tags:
5959
<strong>解释:</strong>
6060
3133 是一个数值平衡数,因为:
6161
- 数字 1 出现 1 次。
62-
- 数字 3 出现 3 次。
62+
- 数字 3 出现 3 次。
6363
这也是严格大于 3000 的最小数值平衡数。
6464
</pre>
6565

solution/2000-2099/2048.Next Greater Numerically Balanced Number/README_EN.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ tags:
3232
<pre>
3333
<strong>Input:</strong> n = 1
3434
<strong>Output:</strong> 22
35-
<strong>Explanation:</strong>
35+
<strong>Explanation:</strong>
3636
22 is numerically balanced since:
37-
- The digit 2 occurs 2 times.
37+
- The digit 2 occurs 2 times.
3838
It is also the smallest numerically balanced number strictly greater than 1.
3939
</pre>
4040

@@ -43,10 +43,10 @@ It is also the smallest numerically balanced number strictly greater than 1.
4343
<pre>
4444
<strong>Input:</strong> n = 1000
4545
<strong>Output:</strong> 1333
46-
<strong>Explanation:</strong>
46+
<strong>Explanation:</strong>
4747
1333 is numerically balanced since:
4848
- The digit 1 occurs 1 time.
49-
- The digit 3 occurs 3 times.
49+
- The digit 3 occurs 3 times.
5050
It is also the smallest numerically balanced number strictly greater than 1000.
5151
Note that 1022 cannot be the answer because 0 appeared more than 0 times.
5252
</pre>
@@ -56,7 +56,7 @@ Note that 1022 cannot be the answer because 0 appeared more than 0 times.
5656
<pre>
5757
<strong>Input:</strong> n = 3000
5858
<strong>Output:</strong> 3133
59-
<strong>Explanation:</strong>
59+
<strong>Explanation:</strong>
6060
3133 is numerically balanced since:
6161
- The digit 1 occurs 1 time.
6262
- The digit 3 occurs 3 times.

solution/3700-3799/3716.Find Churn Risk Customers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tags:
2020

2121
<pre>
2222
+------------------+---------+
23-
| Column Name | Type |
23+
| Column Name | Type |
2424
+------------------+---------+
2525
| event_id | int |
2626
| user_id | int |

solution/3700-3799/3716.Find Churn Risk Customers/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tags:
2020

2121
<pre>
2222
+------------------+---------+
23-
| Column Name | Type |
23+
| Column Name | Type |
2424
+------------------+---------+
2525
| event_id | int |
2626
| user_id | int |

solution/3700-3799/3718.Smallest Missing Multiple of K/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3718.Smallest%20Missing%20Multiple%20of%20K/README.md
5+
rating: 1227
6+
source: 第 472 场周赛 Q1
57
---
68

79
<!-- problem:start -->

solution/3700-3799/3718.Smallest Missing Multiple of K/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3718.Smallest%20Missing%20Multiple%20of%20K/README_EN.md
5+
rating: 1227
6+
source: Weekly Contest 472 Q1
57
---
68

79
<!-- problem:start -->

solution/3700-3799/3719.Longest Balanced Subarray I/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3719.Longest%20Balanced%20Subarray%20I/README.md
5+
rating: 1467
6+
source: 第 472 场周赛 Q2
57
---
68

79
<!-- problem:start -->

solution/3700-3799/3719.Longest Balanced Subarray I/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3719.Longest%20Balanced%20Subarray%20I/README_EN.md
5+
rating: 1467
6+
source: Weekly Contest 472 Q2
57
---
68

79
<!-- problem:start -->

0 commit comments

Comments
 (0)