Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca1ddbe

Browse files
feat: add solutions to lc problem: No.3344 (#3731)
No.3344.Maximum Sized Array
1 parent 4524ae8 commit ca1ddbe

File tree

20 files changed

+661
-26
lines changed

20 files changed

+661
-26
lines changed

‎lcp/LCP 03. 机器人大冒险/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class Solution {
247247
var visited: Set<[Int]> = []
248248
var i = 0, j = 0
249249
visited.insert([i, j])
250-
250+
251251
for c in command {
252252
if c == "U" {
253253
j += 1
@@ -256,16 +256,16 @@ class Solution {
256256
}
257257
visited.insert([i, j])
258258
}
259-
259+
260260
func canReach(_ targetX: Int, _ targetY: Int) -> Bool {
261261
let k = min(targetX / i, targetY / j)
262262
return visited.contains([targetX - k * i, targetY - k * j])
263263
}
264-
264+
265265
if !canReach(x, y) {
266266
return false
267267
}
268-
268+
269269
for obstacle in obstacles {
270270
let obstacleX = obstacle[0]
271271
let obstacleY = obstacle[1]
@@ -276,7 +276,7 @@ class Solution {
276276
return false
277277
}
278278
}
279-
279+
280280
return true
281281
}
282282
}

‎solution/0400-0499/0410.Split Array Largest Sum/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ tags:
2020

2121
<!-- description:start -->
2222

23-
<p>给定一个非负整数数组 <code>nums</code> 和一个整数&nbsp;<code>k</code> ,你需要将这个数组分成&nbsp;<code>k</code><em>&nbsp;</em>个非空的连续子数组。</p>
23+
<p>给定一个非负整数数组 <code>nums</code> 和一个整数&nbsp;<code>k</code> ,你需要将这个数组分成&nbsp;<code>k</code><em>&nbsp;</em>个非空的连续子数组,使得这&nbsp;<code>k</code><em>&nbsp;</em>个子数组各自和的最大值 <strong>最小</strong>。</p>
2424

25-
<p>设计一个算法使得这&nbsp;<code>k</code><em>&nbsp;</em>个子数组各自和的最大值最小。</p>
25+
<p>返回分割后最小的和的最大值。</p>
26+
27+
<p><strong>子数组</strong> 是数组中连续的部份。</p>
2628

2729
<p>&nbsp;</p>
2830

‎solution/0600-0699/0636.Exclusive Time of Functions/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ tags:
3434
<strong>输入:</strong>n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
3535
<strong>输出:</strong>[3,4]
3636
<strong>解释:</strong>
37-
函数 0 在时间戳 0 的起始开始执行,执行 2 个单位时间,于时间戳 1 的末尾结束执行。
38-
函数 1 在时间戳 2 的起始开始执行,执行 4 个单位时间,于时间戳 5 的末尾结束执行。
39-
函数 0 在时间戳 6 的开始恢复执行,执行 1 个单位时间。
40-
所以函数 0 总共执行 2 + 1 = 3 个单位时间,函数 1 总共执行 4 个单位时间。
37+
函数 0 在时间戳 0 的起始开始执行,执行 2 个单位时间,于时间戳 1 的末尾结束执行。
38+
函数 1 在时间戳 2 的起始开始执行,执行 4 个单位时间,于时间戳 5 的末尾结束执行。
39+
函数 0 在时间戳 6 的开始恢复执行,执行 1 个单位时间。
40+
所以函数 0 总共执行 2 + 1 = 3 个单位时间,函数 1 总共执行 4 个单位时间。
4141
</pre>
4242

4343
<p><strong>示例 2:</strong></p>

‎solution/2200-2299/2265.Count Nodes Equal to Average of Subtree/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tags:
3535
<pre>
3636
<strong>Input:</strong> root = [4,8,5,0,1,null,6]
3737
<strong>Output:</strong> 5
38-
<strong>Explanation:</strong>
38+
<strong>Explanation:</strong>
3939
For the node with value 4: The average of its subtree is (4 + 8 + 5 + 0 + 1 + 6) / 6 = 24 / 6 = 4.
4040
For the node with value 5: The average of its subtree is (5 + 6) / 2 = 11 / 2 = 5.
4141
For the node with value 0: The average of its subtree is 0 / 1 = 0.

‎solution/2200-2299/2270.Number of Ways to Split Array/README_EN.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tags:
3636
<pre>
3737
<strong>Input:</strong> nums = [10,4,-8,7]
3838
<strong>Output:</strong> 2
39-
<strong>Explanation:</strong>
39+
<strong>Explanation:</strong>
4040
There are three ways of splitting nums into two non-empty parts:
4141
- Split nums at index 0. Then, the first part is [10], and its sum is 10. The second part is [4,-8,7], and its sum is 3. Since 10 &gt;= 3, i = 0 is a valid split.
4242
- Split nums at index 1. Then, the first part is [10,4], and its sum is 14. The second part is [-8,7], and its sum is -1. Since 14 &gt;= -1, i = 1 is a valid split.
@@ -49,9 +49,9 @@ Thus, the number of valid splits in nums is 2.
4949
<pre>
5050
<strong>Input:</strong> nums = [2,3,1,0]
5151
<strong>Output:</strong> 2
52-
<strong>Explanation:</strong>
52+
<strong>Explanation:</strong>
5353
There are two valid splits in nums:
54-
- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 &gt;= 1, i = 1 is a valid split.
54+
- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 &gt;= 1, i = 1 is a valid split.
5555
- Split nums at index 2. Then, the first part is [2,3,1], and its sum is 6. The second part is [0], and its sum is 0. Since 6 &gt;= 0, i = 2 is a valid split.
5656
</pre>
5757

‎solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tags:
4343
[null, false, false, true, false]
4444

4545
<strong>解释:</strong>
46-
DataStream dataStream = new DataStream(4, 3); // value = 4, k = 3
46+
DataStream dataStream = new DataStream(4, 3); // value = 4, k = 3
4747
dataStream.consec(4); // 数据流中只有 1 个整数,所以返回 False 。
4848
dataStream.consec(4); // 数据流中只有 2 个整数
4949
// 由于 2 小于 k ,返回 False 。

‎solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README_EN.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ tags:
4242
[null, false, false, true, false]
4343

4444
<strong>Explanation</strong>
45-
DataStream dataStream = new DataStream(4, 3); //value = 4, k = 3
46-
dataStream.consec(4); // Only 1 integer is parsed, so returns False.
45+
DataStream dataStream = new DataStream(4, 3); //value = 4, k = 3
46+
dataStream.consec(4); // Only 1 integer is parsed, so returns False.
4747
dataStream.consec(4); // Only 2 integers are parsed.
48-
// Since 2 is less than k, returns False.
49-
dataStream.consec(4); // The 3 integers parsed are all equal to value, so returns True.
48+
// Since 2 is less than k, returns False.
49+
dataStream.consec(4); // The 3 integers parsed are all equal to value, so returns True.
5050
dataStream.consec(3); // The last k integers parsed in the stream are [4,4,3].
5151
// Since 3 is not equal to value, it returns False.
5252
</pre>

‎solution/2500-2599/2528.Maximize the Minimum Powered City/README_EN.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ tags:
4545
<pre>
4646
<strong>Input:</strong> stations = [1,2,4,5,0], r = 1, k = 2
4747
<strong>Output:</strong> 5
48-
<strong>Explanation:</strong>
49-
One of the optimal ways is to install both the power stations at city 1.
48+
<strong>Explanation:</strong>
49+
One of the optimal ways is to install both the power stations at city 1.
5050
So stations will become [1,4,4,5,0].
5151
- City 0 is provided by 1 + 4 = 5 power stations.
5252
- City 1 is provided by 1 + 4 + 4 = 9 power stations.
@@ -62,7 +62,7 @@ Since it is not possible to obtain a larger power, we return 5.
6262
<pre>
6363
<strong>Input:</strong> stations = [4,4,4,4], r = 0, k = 3
6464
<strong>Output:</strong> 4
65-
<strong>Explanation:</strong>
65+
<strong>Explanation:</strong>
6666
It can be proved that we cannot make the minimum power of a city greater than 4.
6767
</pre>
6868

‎solution/2500-2599/2530.Maximal Score After Applying K Operations/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tags:
5151
<strong>Explanation: </strong>You can do the following operations:
5252
Operation 1: Select i = 1, so nums becomes [1,<strong><u>4</u></strong>,3,3,3]. Your score increases by 10.
5353
Operation 2: Select i = 1, so nums becomes [1,<strong><u>2</u></strong>,3,3,3]. Your score increases by 4.
54-
Operation 3: Select i = 2, so nums becomes [1,1,<u><strong>1</strong></u>,3,3]. Your score increases by 3.
54+
Operation 3: Select i = 2, so nums becomes [1,2,<u><strong>1</strong></u>,3,3]. Your score increases by 3.
5555
The final score is 10 + 4 + 3 = 17.
5656
</pre>
5757

‎solution/3200-3299/3222.Find the Winning Player in Coin Game/README.md‎

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

2323
<p>给你两个 <strong>正</strong>&nbsp;整数&nbsp;<code>x</code>&nbsp;&nbsp;<code>y</code>&nbsp;,分别表示价值为 75 和 10 的硬币的数目。</p>
2424

25-
<p>Alice 和 Bob 正在玩一个游戏。每一轮中,Alice&nbsp;先进行操作,Bob 后操作。每次操作中,玩家需要拿出价值 <b>总和</b>&nbsp;为 115 的硬币。如果一名玩家无法执行此操作,那么这名玩家 <strong>输掉</strong>&nbsp;游戏。</p>
25+
<p>Alice 和 Bob 正在玩一个游戏。每一轮中,Alice&nbsp;先进行操作,Bob 后操作。每次操作中,玩家需要拿走价值 <b>总和</b>&nbsp;为 115 的硬币。如果一名玩家无法执行此操作,那么这名玩家 <strong>输掉</strong>&nbsp;游戏。</p>
2626

2727
<p>两名玩家都采取 <strong>最优</strong>&nbsp;策略,请你返回游戏的赢家。</p>
2828

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /