Skip to content

Commit 75d47fc

Browse files
authoredSep 4, 2024··
feat: update lc problems (#3488)
1 parent a776c16 commit 75d47fc

File tree

33 files changed

+137
-69
lines changed

33 files changed

+137
-69
lines changed
 

‎lcof2/剑指 Offer II 086. 分割回文子字符串/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ class Solution {
299299
n = s.count
300300
self.s = s
301301
f = Array(repeating: Array(repeating: true, count: n), count: n)
302-
302+
303303
let chars = Array(s)
304-
304+
305305
for i in stride(from: n - 1, through: 0, by: -1) {
306306
for j in i + 1 ..< n {
307307
f[i][j] = chars[i] == chars[j] && f[i + 1][j - 1]
308308
}
309309
}
310-
310+
311311
dfs(0)
312312
return ans
313313
}

‎lcof2/剑指 Offer II 092. 翻转字符/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,22 @@ class Solution {
188188
let n = s.count
189189
var left0 = 0, right0 = 0
190190
let chars = Array(s)
191-
191+
192192
for char in chars {
193193
if char == "0" {
194194
right0 += 1
195195
}
196196
}
197-
197+
198198
var ans = min(right0, n - right0)
199-
199+
200200
for i in 1...n {
201201
let x = chars[i - 1] == "0" ? 0 : 1
202202
right0 -= x ^ 1
203203
left0 += x ^ 1
204204
ans = min(ans, i - left0 + right0)
205205
}
206-
206+
207207
return ans
208208
}
209209
}

‎lcof2/剑指 Offer II 093. 最长斐波那契数列/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ class Solution {
198198
for i in 0..<n {
199199
mp[arr[i]] = i
200200
}
201-
201+
202202
var dp = Array(repeating: Array(repeating: 2, count: n), count: n)
203203
var ans = 0
204-
204+
205205
for i in 0..<n {
206206
for j in 0..<i {
207207
let delta = arr[i] - arr[j]
@@ -211,7 +211,7 @@ class Solution {
211211
}
212212
}
213213
}
214-
214+
215215
return ans > 2 ? ans : 0
216216
}
217217
}

‎lcof2/剑指 Offer II 094. 最少回文分割/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,28 @@ class Solution {
256256
func minCut(_ s: String) -> Int {
257257
let n = s.count
258258
let sArray = Array(s)
259-
259+
260260
var g = Array(repeating: Array(repeating: true, count: n), count: n)
261-
261+
262262
for i in stride(from: n - 1, through: 0, by: -1) {
263263
for j in i + 1..<n {
264264
g[i][j] = sArray[i] == sArray[j] && g[i + 1][j - 1]
265265
}
266266
}
267-
267+
268268
var f = Array(repeating: 0, count: n)
269269
for i in 0..<n {
270270
f[i] = i
271271
}
272-
272+
273273
for i in 1..<n {
274274
for j in 0...i {
275275
if g[j][i] {
276276
f[i] = min(f[i], j > 0 ? 1 + f[j - 1] : 0)
277277
}
278278
}
279279
}
280-
280+
281281
return f[n - 1]
282282
}
283283
}

‎lcof2/剑指 Offer II 096. 字符串交织/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,11 @@ class Solution {
694694
if m + n != s3.count {
695695
return false
696696
}
697-
697+
698698
let s1 = Array(s1), s2 = Array(s2), s3 = Array(s3)
699699
var dp = Array(repeating: Array(repeating: false, count: n + 1), count: m + 1)
700700
dp[0][0] = true
701-
701+
702702
for i in 0...m {
703703
for j in 0...n {
704704
let k = i + j - 1
@@ -710,7 +710,7 @@ class Solution {
710710
}
711711
}
712712
}
713-
713+
714714
return dp[m][n]
715715
}
716716
}

‎solution/2800-2899/2860.Happy Students/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class Solution:
103103
continue
104104
if i < n and nums[i] <= i:
105105
continue
106+
ans += 1
106107
return ans
107108
```
108109

‎solution/2800-2899/2860.Happy Students/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class Solution:
101101
continue
102102
if i < n and nums[i] <= i:
103103
continue
104+
ans += 1
104105
return ans
105106
```
106107

‎solution/2800-2899/2860.Happy Students/Solution.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ def countWays(self, nums: List[int]) -> int:
88
continue
99
if i < n and nums[i] <= i:
1010
continue
11+
ans += 1
1112
return ans

‎solution/2900-2999/2976.Minimum Cost to Convert String I/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ tags:
5353
<strong>输入:</strong>source = "aaaa", target = "bbbb", original = ["a","c"], changed = ["c","b"], cost = [1,2]
5454
<strong>输出:</strong>12
5555
<strong>解释:</strong>要将字符 'a' 更改为 'b':
56-
- 将字符 'a' 更改为 'c',成本为 1
57-
- 将字符 'c' 更改为 'b',成本为 2
56+
- 将字符 'a' 更改为 'c',成本为 1
57+
- 将字符 'c' 更改为 'b',成本为 2
5858
产生的总成本是 1 + 2 = 3。
5959
将所有 'a' 更改为 'b',产生的总成本是 3 * 4 = 12 。
6060
</pre>

‎solution/3200-3299/3268.Find Overlapping Shifts II/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ tags:
3030
这张表包含员工的排班工作,包括特定日期的开始和结束时间。
3131
</pre>
3232

33-
<p>编写一个解决方案来为每个员工分析重叠排班。如果一个排班的&nbsp;<code>end_time</code>&nbsp;比另一个排班的&nbsp;<code>start_time</code>&nbsp;<strong>更晚&nbsp;</strong>则认为两个排班重叠。</p>
33+
<p>编写一个解决方案来为每个员工分析重叠排班。如果两个排班在&nbsp;<strong>同一天</strong>&nbsp;且一个排班的&nbsp;<code>end_time</code>&nbsp;比另一个排班的&nbsp;<code>start_time</code>&nbsp;<strong>更晚&nbsp;</strong>则认为两个排班重叠。</p>
3434

3535
<p>对于&nbsp;<strong>每个员工</strong>,计算如下内容:</p>
3636

3737
<ol>
38-
<li>任何 <strong>给定时间</strong><strong>重叠&nbsp;</strong>的 <strong>最大</strong> 班次数。</li>
38+
<li>任何 <strong>给定时间</strong> 的 <strong>最多重叠</strong> 班次数。</li>
3939
<li>所有重叠班次的 <strong>总持续时间</strong>,以分钟为单位。</li>
4040
</ol>
4141

‎solution/3200-3299/3269.Constructing Two Increasing Arrays/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README.md
5+
tags:
6+
- 数组
7+
- 动态规划
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3269.Constructing Two Increasing Arrays/README_EN.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README_EN.md
5+
tags:
6+
- Array
7+
- Dynamic Programming
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3270.Find the Key of the Numbers/README.md

+2
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/3200-3299/3270.Find%20the%20Key%20of%20the%20Numbers/README.md
5+
tags:
6+
- 数学
57
---
68

79
<!-- problem:start -->

‎solution/3200-3299/3270.Find the Key of the Numbers/README_EN.md

+2
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/3200-3299/3270.Find%20the%20Key%20of%20the%20Numbers/README_EN.md
5+
tags:
6+
- Math
57
---
68

79
<!-- problem:start -->

‎solution/3200-3299/3271.Hash Divided String/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3271.Hash%20Divided%20String/README.md
5+
tags:
6+
- 字符串
7+
- 模拟
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3271.Hash Divided String/README_EN.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3271.Hash%20Divided%20String/README_EN.md
5+
tags:
6+
- String
7+
- Simulation
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3272.Find the Count of Good Integers/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3272.Find%20the%20Count%20of%20Good%20Integers/README.md
5+
tags:
6+
- 哈希表
7+
- 数学
8+
- 组合数学
9+
- 枚举
510
---
611

712
<!-- problem:start -->

‎solution/3200-3299/3272.Find the Count of Good Integers/README_EN.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3272.Find%20the%20Count%20of%20Good%20Integers/README_EN.md
5+
tags:
6+
- Hash Table
7+
- Math
8+
- Combinatorics
9+
- Enumeration
510
---
611

712
<!-- problem:start -->

‎solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3273.Minimum%20Amount%20of%20Damage%20Dealt%20to%20Bob/README.md
5+
tags:
6+
- 贪心
7+
- 数组
8+
- 排序
59
---
610

711
<!-- problem:start -->

‎solution/3200-3299/3273.Minimum Amount of Damage Dealt to Bob/README_EN.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3273.Minimum%20Amount%20of%20Damage%20Dealt%20to%20Bob/README_EN.md
5+
tags:
6+
- Greedy
7+
- Array
8+
- Sorting
59
---
610

711
<!-- problem:start -->

‎solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3274.Check%20if%20Two%20Chessboard%20Squares%20Have%20the%20Same%20Color/README.md
5+
tags:
6+
- 数学
7+
- 字符串
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3274.Check if Two Chessboard Squares Have the Same Color/README_EN.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3274.Check%20if%20Two%20Chessboard%20Squares%20Have%20the%20Same%20Color/README_EN.md
5+
tags:
6+
- Math
7+
- String
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3275.K-th Nearest Obstacle Queries/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3275.K-th%20Nearest%20Obstacle%20Queries/README.md
5+
tags:
6+
- 数组
7+
- 堆(优先队列)
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3275.K-th Nearest Obstacle Queries/README_EN.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3275.K-th%20Nearest%20Obstacle%20Queries/README_EN.md
5+
tags:
6+
- Array
7+
- Heap (Priority Queue)
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3276.Select%20Cells%20in%20Grid%20With%20Maximum%20Score/README.md
5+
tags:
6+
- 位运算
7+
- 数组
8+
- 动态规划
9+
- 状态压缩
10+
- 矩阵
511
---
612

713
<!-- problem:start -->

‎solution/3200-3299/3276.Select Cells in Grid With Maximum Score/README_EN.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3276.Select%20Cells%20in%20Grid%20With%20Maximum%20Score/README_EN.md
5+
tags:
6+
- Bit Manipulation
7+
- Array
8+
- Dynamic Programming
9+
- Bitmask
10+
- Matrix
511
---
612

713
<!-- problem:start -->

‎solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3277.Maximum%20XOR%20Score%20Subarray%20Queries/README.md
5+
tags:
6+
- 数组
7+
- 动态规划
58
---
69

710
<!-- problem:start -->

‎solution/3200-3299/3277.Maximum XOR Score Subarray Queries/README_EN.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3277.Maximum%20XOR%20Score%20Subarray%20Queries/README_EN.md
5+
tags:
6+
- Array
7+
- Dynamic Programming
58
---
69

710
<!-- problem:start -->

0 commit comments

Comments
 (0)
Please sign in to comment.