diff --git "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md" "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md" index d79bb292503a2..f3a58cc62caa7 100644 --- "a/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md" +++ "b/lcp/LCP 07. \344\274\240\351\200\222\344\277\241\346\201\257/README.md" @@ -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] @@ -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 { @@ -292,7 +292,7 @@ class Solution { f = g steps -= 1 } - + return f[n - 1] } } diff --git "a/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md" "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md" index da2ee732ca727..02c7840200690 100644 --- "a/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md" +++ "b/lcp/LCP 09. \346\234\200\345\260\217\350\267\263\350\267\203\346\254\241\346\225\260/README.md" @@ -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..= n { return ans } - + if !vis[forwardJump] { queue.append(forwardJump) vis[forwardJump] = true } - + while maxReach < i { if !vis[maxReach] { queue.append(maxReach) @@ -216,7 +216,7 @@ class Solution { } } } - + return -1 } } diff --git "a/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md" "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md" index e0acb3b6c74f8..88a761b550252 100644 --- "a/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md" +++ "b/lcp/LCP 10. \344\272\214\345\217\211\346\240\221\344\273\273\345\212\241\350\260\203\345\272\246/README.md" @@ -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] } } diff --git a/solution/3300-3399/3345.Smallest Divisible Digit Product I/README.md b/solution/3300-3399/3345.Smallest Divisible Digit Product I/README.md index 3a7aea20ef15f..25491b2565355 100644 --- a/solution/3300-3399/3345.Smallest Divisible Digit Product I/README.md +++ b/solution/3300-3399/3345.Smallest Divisible Digit Product I/README.md @@ -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: + - 数学 + - 枚举 --- diff --git a/solution/3300-3399/3345.Smallest Divisible Digit Product I/README_EN.md b/solution/3300-3399/3345.Smallest Divisible Digit Product I/README_EN.md index 16c5c43cf2527..f591a447c1179 100644 --- a/solution/3300-3399/3345.Smallest Divisible Digit Product I/README_EN.md +++ b/solution/3300-3399/3345.Smallest Divisible Digit Product I/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README.md b/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README.md index 9cb434c9d2303..c7782740dbe39 100644 --- a/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README.md +++ b/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README.md @@ -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: + - 数组 + - 二分查找 + - 前缀和 + - 排序 + - 滑动窗口 --- diff --git a/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README_EN.md b/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README_EN.md index 90d1f4e566399..9009599f43836 100644 --- a/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README_EN.md +++ b/solution/3300-3399/3346.Maximum Frequency of an Element After Performing Operations I/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README.md b/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README.md index e6209c5ee3dc7..2f46f13f201ce 100644 --- a/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README.md +++ b/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README.md @@ -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: + - 数组 + - 二分查找 + - 前缀和 + - 排序 + - 滑动窗口 --- diff --git a/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README_EN.md b/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README_EN.md index 083ac9225981b..67de03c177cf9 100644 --- a/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README_EN.md +++ b/solution/3300-3399/3347.Maximum Frequency of an Element After Performing Operations II/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3348.Smallest Divisible Digit Product II/README.md b/solution/3300-3399/3348.Smallest Divisible Digit Product II/README.md index b26733e5d41e7..06c98fe576091 100644 --- a/solution/3300-3399/3348.Smallest Divisible Digit Product II/README.md +++ b/solution/3300-3399/3348.Smallest Divisible Digit Product II/README.md @@ -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: + - 贪心 + - 数学 + - 字符串 + - 回溯 + - 数论 --- diff --git a/solution/3300-3399/3348.Smallest Divisible Digit Product II/README_EN.md b/solution/3300-3399/3348.Smallest Divisible Digit Product II/README_EN.md index 01619b6872e72..1021936f1e9b8 100644 --- a/solution/3300-3399/3348.Smallest Divisible Digit Product II/README_EN.md +++ b/solution/3300-3399/3348.Smallest Divisible Digit Product II/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README.md b/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README.md index 40f2249c4d5de..93dc8ad0804ca 100644 --- a/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README.md +++ b/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README.md @@ -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: + - 数组 --- diff --git a/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README_EN.md b/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README_EN.md index a463fa34e6863..482a98a0c0eb1 100644 --- a/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README_EN.md +++ b/solution/3300-3399/3349.Adjacent Increasing Subarrays Detection I/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README.md b/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README.md index ef1f0f15afcf5..5b977d848afc7 100644 --- a/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README.md +++ b/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README.md @@ -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: + - 数组 + - 二分查找 --- diff --git a/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README_EN.md b/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README_EN.md index 264f7632da708..e9386411c38af 100644 --- a/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README_EN.md +++ b/solution/3300-3399/3350.Adjacent Increasing Subarrays Detection II/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3351.Sum of Good Subsequences/README.md b/solution/3300-3399/3351.Sum of Good Subsequences/README.md index 295551361d4df..eb21cc0a5e4d7 100644 --- a/solution/3300-3399/3351.Sum of Good Subsequences/README.md +++ b/solution/3300-3399/3351.Sum of Good Subsequences/README.md @@ -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: + - 数组 + - 哈希表 + - 动态规划 --- diff --git a/solution/3300-3399/3351.Sum of Good Subsequences/README_EN.md b/solution/3300-3399/3351.Sum of Good Subsequences/README_EN.md index 4a7b355323edc..f528043cdd817 100644 --- a/solution/3300-3399/3351.Sum of Good Subsequences/README_EN.md +++ b/solution/3300-3399/3351.Sum of Good Subsequences/README_EN.md @@ -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 --- diff --git a/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README.md b/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README.md index df50afc6d0217..56aebfe937606 100644 --- a/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README.md +++ b/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README.md @@ -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: + - 数学 + - 字符串 + - 动态规划 + - 组合数学 --- diff --git a/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README_EN.md b/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README_EN.md index 0aa9eb4ad91c4..e241caf2b721a 100644 --- a/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README_EN.md +++ b/solution/3300-3399/3352.Count K-Reducible Numbers Less Than N/README_EN.md @@ -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 --- diff --git a/solution/README.md b/solution/README.md index 295aa66d1b4ee..0b8b2024a1177 100644 --- a/solution/README.md +++ b/solution/README.md @@ -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 场周赛 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index 8587f89656ce2..102754795d988 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -3353,14 +3353,14 @@ Press Control + F(or Command + F 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