Skip to content
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

chore: update lc problems #3751

Merged
merged 1 commit into from
Nov 12, 2024
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
6 changes: 3 additions & 3 deletions lcp/LCP 07. 传递信息/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ 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]
Expand Down Expand Up @@ -282,7 +282,7 @@ class Solution {
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 {
Expand All @@ -292,7 +292,7 @@ class Solution {
f = g
steps -= 1
}

return f[n - 1]
}
}
Expand Down
12 changes: 6 additions & 6 deletions lcp/LCP 09. 最小跳跃次数/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,24 @@ class Solution {
vis[0] = true
var ans = 0
var maxReach = 1

while !queue.isEmpty {
ans += 1
let size = queue.count

for _ in 0..<size {
let i = queue.removeFirst()

let forwardJump = i + jump[i]
if forwardJump >= n {
return ans
}

if !vis[forwardJump] {
queue.append(forwardJump)
vis[forwardJump] = true
}

while maxReach < i {
if !vis[maxReach] {
queue.append(maxReach)
Expand All @@ -216,7 +216,7 @@ class Solution {
}
}
}

return -1
}
}
Expand Down
8 changes: 4 additions & 4 deletions lcp/LCP 10. 二叉树任务调度/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,16 @@ 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]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README.md
tags:
- 数学
- 枚举
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README_EN.md
tags:
- Math
- Enumeration
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README.md
tags:
- 数组
- 二分查找
- 前缀和
- 排序
- 滑动窗口
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README_EN.md
tags:
- Array
- Binary Search
- Prefix Sum
- Sorting
- Sliding Window
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README.md
tags:
- 数组
- 二分查找
- 前缀和
- 排序
- 滑动窗口
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README_EN.md
tags:
- Array
- Binary Search
- Prefix Sum
- Sorting
- Sliding Window
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README.md
tags:
- 贪心
- 数学
- 字符串
- 回溯
- 数论
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README_EN.md
tags:
- Greedy
- Math
- String
- Backtracking
- Number Theory
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README.md
tags:
- 数组
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README_EN.md
tags:
- Array
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README.md
tags:
- 数组
- 二分查找
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README_EN.md
tags:
- Array
- Binary Search
---

<!-- problem:start -->
Expand Down
4 changes: 4 additions & 0 deletions solution/3300-3399/3351.Sum of Good Subsequences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README.md
tags:
- 数组
- 哈希表
- 动态规划
---

<!-- problem:start -->
Expand Down
4 changes: 4 additions & 0 deletions solution/3300-3399/3351.Sum of Good Subsequences/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README_EN.md
tags:
- Array
- Hash Table
- Dynamic Programming
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README.md
tags:
- 数学
- 字符串
- 动态规划
- 组合数学
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README_EN.md
tags:
- Math
- String
- Dynamic Programming
- Combinatorics
---

<!-- problem:start -->
Expand Down
16 changes: 8 additions & 8 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3355,14 +3355,14 @@
| 3342 | [到达最后一个房间的最少时间 II](/solution/3300-3399/3342.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20II/README.md) | `图`,`数组`,`矩阵`,`最短路`,`堆(优先队列)` | 中等 | 第 422 场周赛 |
| 3343 | [统计平衡排列的数目](/solution/3300-3399/3343.Count%20Number%20of%20Balanced%20Permutations/README.md) | `数学`,`字符串`,`动态规划`,`组合数学` | 困难 | 第 422 场周赛 |
| 3344 | [最大尺寸数组](/solution/3300-3399/3344.Maximum%20Sized%20Array/README.md) | `位运算`,`二分查找` | 中等 | 🔒 |
| 3345 | [最小可整除数位乘积 I](/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README.md) | | 简单 | 第 143 场双周赛 |
| 3346 | [执行操作后元素的最高频率 I](/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README.md) | | 中等 | 第 143 场双周赛 |
| 3347 | [执行操作后元素的最高频率 II](/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README.md) | | 困难 | 第 143 场双周赛 |
| 3348 | [最小可整除数位乘积 II](/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README.md) | | 困难 | 第 143 场双周赛 |
| 3349 | [检测相邻递增子数组 I](/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README.md) | | 简单 | 第 423 场周赛 |
| 3350 | [检测相邻递增子数组 II](/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README.md) | | 中等 | 第 423 场周赛 |
| 3351 | [好子序列的元素之和](/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README.md) | | 困难 | 第 423 场周赛 |
| 3352 | [统计小于 N 的 K 可约简整数](/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README.md) | | 困难 | 第 423 场周赛 |
| 3345 | [最小可整除数位乘积 I](/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README.md) | `数学`,`枚举` | 简单 | 第 143 场双周赛 |
| 3346 | [执行操作后元素的最高频率 I](/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README.md) | `数组`,`二分查找`,`前缀和`,`排序`,`滑动窗口` | 中等 | 第 143 场双周赛 |
| 3347 | [执行操作后元素的最高频率 II](/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README.md) | `数组`,`二分查找`,`前缀和`,`排序`,`滑动窗口` | 困难 | 第 143 场双周赛 |
| 3348 | [最小可整除数位乘积 II](/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README.md) | `贪心`,`数学`,`字符串`,`回溯`,`数论` | 困难 | 第 143 场双周赛 |
| 3349 | [检测相邻递增子数组 I](/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README.md) | `数组` | 简单 | 第 423 场周赛 |
| 3350 | [检测相邻递增子数组 II](/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README.md) | `数组`,`二分查找` | 中等 | 第 423 场周赛 |
| 3351 | [好子序列的元素之和](/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README.md) | `数组`,`哈希表`,`动态规划` | 困难 | 第 423 场周赛 |
| 3352 | [统计小于 N 的 K 可约简整数](/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README.md) | `数学`,`字符串`,`动态规划`,`组合数学` | 困难 | 第 423 场周赛 |

## 版权

Expand Down
16 changes: 8 additions & 8 deletions solution/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3353,14 +3353,14 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 3342 | [Find Minimum Time to Reach Last Room II](/solution/3300-3399/3342.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20II/README_EN.md) | `Graph`,`Array`,`Matrix`,`Shortest Path`,`Heap (Priority Queue)` | Medium | Weekly Contest 422 |
| 3343 | [Count Number of Balanced Permutations](/solution/3300-3399/3343.Count%20Number%20of%20Balanced%20Permutations/README_EN.md) | `Math`,`String`,`Dynamic Programming`,`Combinatorics` | Hard | Weekly Contest 422 |
| 3344 | [Maximum Sized Array](/solution/3300-3399/3344.Maximum%20Sized%20Array/README_EN.md) | `Bit Manipulation`,`Binary Search` | Medium | 🔒 |
| 3345 | [Smallest Divisible Digit Product I](/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README_EN.md) | | Easy | Biweekly Contest 143 |
| 3346 | [Maximum Frequency of an Element After Performing Operations I](/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README_EN.md) | | Medium | Biweekly Contest 143 |
| 3347 | [Maximum Frequency of an Element After Performing Operations II](/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README_EN.md) | | Hard | Biweekly Contest 143 |
| 3348 | [Smallest Divisible Digit Product II](/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README_EN.md) | | Hard | Biweekly Contest 143 |
| 3349 | [Adjacent Increasing Subarrays Detection I](/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README_EN.md) | | Easy | Weekly Contest 423 |
| 3350 | [Adjacent Increasing Subarrays Detection II](/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README_EN.md) | | Medium | Weekly Contest 423 |
| 3351 | [Sum of Good Subsequences](/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README_EN.md) | | Hard | Weekly Contest 423 |
| 3352 | [Count K-Reducible Numbers Less Than N](/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README_EN.md) | | Hard | Weekly Contest 423 |
| 3345 | [Smallest Divisible Digit Product I](/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README_EN.md) | `Math`,`Enumeration` | Easy | Biweekly Contest 143 |
| 3346 | [Maximum Frequency of an Element After Performing Operations I](/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README_EN.md) | `Array`,`Binary Search`,`Prefix Sum`,`Sorting`,`Sliding Window` | Medium | Biweekly Contest 143 |
| 3347 | [Maximum Frequency of an Element After Performing Operations II](/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README_EN.md) | `Array`,`Binary Search`,`Prefix Sum`,`Sorting`,`Sliding Window` | Hard | Biweekly Contest 143 |
| 3348 | [Smallest Divisible Digit Product II](/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README_EN.md) | `Greedy`,`Math`,`String`,`Backtracking`,`Number Theory` | Hard | Biweekly Contest 143 |
| 3349 | [Adjacent Increasing Subarrays Detection I](/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README_EN.md) | `Array` | Easy | Weekly Contest 423 |
| 3350 | [Adjacent Increasing Subarrays Detection II](/solution/3300-3399/3350.Adjacent%20Increasing%20Subarrays%20Detection%20II/README_EN.md) | `Array`,`Binary Search` | Medium | Weekly Contest 423 |
| 3351 | [Sum of Good Subsequences](/solution/3300-3399/3351.Sum%20of%20Good%20Subsequences/README_EN.md) | `Array`,`Hash Table`,`Dynamic Programming` | Hard | Weekly Contest 423 |
| 3352 | [Count K-Reducible Numbers Less Than N](/solution/3300-3399/3352.Count%20K-Reducible%20Numbers%20Less%20Than%20N/README_EN.md) | `Math`,`String`,`Dynamic Programming`,`Combinatorics` | Hard | Weekly Contest 423 |

## Copyright

Expand Down
Loading