diff --git a/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README.md b/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README.md index 08b71be95dc0a..356a653a644e2 100644 --- a/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README.md +++ b/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3300.Minimum%20Element%20After%20Replacement%20With%20Digit%20Sum/README.md +rating: 1181 +source: 第 140 场双周赛 Q1 tags: - 数组 - 数学 diff --git a/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README_EN.md b/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README_EN.md index 1648c530afb36..6b730deca9d6c 100644 --- a/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README_EN.md +++ b/solution/3300-3399/3300.Minimum Element After Replacement With Digit Sum/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3300.Minimum%20Element%20After%20Replacement%20With%20Digit%20Sum/README_EN.md +rating: 1181 +source: Biweekly Contest 140 Q1 tags: - Array - Math diff --git a/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README.md b/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README.md index e9eefa1b8ccf2..9432d2b08cdfd 100644 --- a/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README.md +++ b/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3301.Maximize%20the%20Total%20Height%20of%20Unique%20Towers/README.md +rating: 1448 +source: 第 140 场双周赛 Q2 tags: - 贪心 - 数组 diff --git a/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README_EN.md b/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README_EN.md index 3d16aff13c249..b516234fb2862 100644 --- a/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README_EN.md +++ b/solution/3300-3399/3301.Maximize the Total Height of Unique Towers/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3301.Maximize%20the%20Total%20Height%20of%20Unique%20Towers/README_EN.md +rating: 1448 +source: Biweekly Contest 140 Q2 tags: - Greedy - Array diff --git a/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README.md b/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README.md index f7a252badfdb1..dc6aca161b065 100644 --- a/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README.md +++ b/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3302.Find%20the%20Lexicographically%20Smallest%20Valid%20Sequence/README.md +rating: 2473 +source: 第 140 场双周赛 Q3 tags: - 贪心 - 双指针 diff --git a/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README_EN.md b/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README_EN.md index 67678d2d9c8a6..066dfffe10e12 100644 --- a/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README_EN.md +++ b/solution/3300-3399/3302.Find the Lexicographically Smallest Valid Sequence/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3302.Find%20the%20Lexicographically%20Smallest%20Valid%20Sequence/README_EN.md +rating: 2473 +source: Biweekly Contest 140 Q3 tags: - Greedy - Two Pointers diff --git a/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README.md b/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README.md index 65a8e2ca1843f..7a8854d6017df 100644 --- a/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README.md +++ b/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3303.Find%20the%20Occurrence%20of%20First%20Almost%20Equal%20Substring/README.md +rating: 2509 +source: 第 140 场双周赛 Q4 tags: - 字符串 - 字符串匹配 diff --git a/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README_EN.md b/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README_EN.md index f71839f655b38..f53c65671e1dd 100644 --- a/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README_EN.md +++ b/solution/3300-3399/3303.Find the Occurrence of First Almost Equal Substring/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3303.Find%20the%20Occurrence%20of%20First%20Almost%20Equal%20Substring/README_EN.md +rating: 2509 +source: Biweekly Contest 140 Q4 tags: - String - String Matching diff --git a/solution/3300-3399/3304.Find the K-th Character in String Game I/README.md b/solution/3300-3399/3304.Find the K-th Character in String Game I/README.md index a50f1951d0652..1fd83b1df8404 100644 --- a/solution/3300-3399/3304.Find the K-th Character in String Game I/README.md +++ b/solution/3300-3399/3304.Find the K-th Character in String Game I/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3304.Find%20the%20K-th%20Character%20in%20String%20Game%20I/README.md +rating: 1288 +source: 第 417 场周赛 Q1 tags: - 位运算 - 递归 diff --git a/solution/3300-3399/3304.Find the K-th Character in String Game I/README_EN.md b/solution/3300-3399/3304.Find the K-th Character in String Game I/README_EN.md index 06856a43134a3..939cfd227d1d8 100644 --- a/solution/3300-3399/3304.Find the K-th Character in String Game I/README_EN.md +++ b/solution/3300-3399/3304.Find the K-th Character in String Game I/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3304.Find%20the%20K-th%20Character%20in%20String%20Game%20I/README_EN.md +rating: 1288 +source: Weekly Contest 417 Q1 tags: - Bit Manipulation - Recursion diff --git a/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README.md b/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README.md index 91a70fbc09f85..7c83260a49fac 100644 --- a/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README.md +++ b/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3305.Count%20of%20Substrings%20Containing%20Every%20Vowel%20and%20K%20Consonants%20I/README.md +rating: 1563 +source: 第 417 场周赛 Q2 tags: - 哈希表 - 字符串 diff --git a/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README_EN.md b/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README_EN.md index f0f4c0a13d96a..598811e3ce166 100644 --- a/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README_EN.md +++ b/solution/3300-3399/3305.Count of Substrings Containing Every Vowel and K Consonants I/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3305.Count%20of%20Substrings%20Containing%20Every%20Vowel%20and%20K%20Consonants%20I/README_EN.md +rating: 1563 +source: Weekly Contest 417 Q2 tags: - Hash Table - String diff --git a/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README.md b/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README.md index 757f4c6b74ef9..b3ac427988c86 100644 --- a/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README.md +++ b/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3306.Count%20of%20Substrings%20Containing%20Every%20Vowel%20and%20K%20Consonants%20II/README.md +rating: 2200 +source: 第 417 场周赛 Q3 tags: - 哈希表 - 字符串 diff --git a/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README_EN.md b/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README_EN.md index 03075272f022d..7eebace7f697f 100644 --- a/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README_EN.md +++ b/solution/3300-3399/3306.Count of Substrings Containing Every Vowel and K Consonants II/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3306.Count%20of%20Substrings%20Containing%20Every%20Vowel%20and%20K%20Consonants%20II/README_EN.md +rating: 2200 +source: Weekly Contest 417 Q3 tags: - Hash Table - String diff --git a/solution/3300-3399/3307.Find the K-th Character in String Game II/README.md b/solution/3300-3399/3307.Find the K-th Character in String Game II/README.md index 13a95c0ded9a8..52d5b2cd7006f 100644 --- a/solution/3300-3399/3307.Find the K-th Character in String Game II/README.md +++ b/solution/3300-3399/3307.Find the K-th Character in String Game II/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3307.Find%20the%20K-th%20Character%20in%20String%20Game%20II/README.md +rating: 2232 +source: 第 417 场周赛 Q4 tags: - 位运算 - 递归 diff --git a/solution/3300-3399/3307.Find the K-th Character in String Game II/README_EN.md b/solution/3300-3399/3307.Find the K-th Character in String Game II/README_EN.md index 8635d053b989e..cc462b29287a5 100644 --- a/solution/3300-3399/3307.Find the K-th Character in String Game II/README_EN.md +++ b/solution/3300-3399/3307.Find the K-th Character in String Game II/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3307.Find%20the%20K-th%20Character%20in%20String%20Game%20II/README_EN.md +rating: 2232 +source: Weekly Contest 417 Q4 tags: - Bit Manipulation - Recursion diff --git a/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README.md b/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README.md index 9095d32d79051..2a97b3797bb09 100644 --- a/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README.md +++ b/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3309.Maximum%20Possible%20Number%20by%20Binary%20Concatenation/README.md +rating: 1363 +source: 第 418 场周赛 Q1 tags: - 位运算 - 数组 diff --git a/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README_EN.md b/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README_EN.md index 13d7040540966..af5556ef6cbc7 100644 --- a/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README_EN.md +++ b/solution/3300-3399/3309.Maximum Possible Number by Binary Concatenation/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3309.Maximum%20Possible%20Number%20by%20Binary%20Concatenation/README_EN.md +rating: 1363 +source: Weekly Contest 418 Q1 tags: - Bit Manipulation - Array diff --git a/solution/3300-3399/3310.Remove Methods From Project/README.md b/solution/3300-3399/3310.Remove Methods From Project/README.md index e811825821432..7146246f7919c 100644 --- a/solution/3300-3399/3310.Remove Methods From Project/README.md +++ b/solution/3300-3399/3310.Remove Methods From Project/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3310.Remove%20Methods%20From%20Project/README.md +rating: 1710 +source: 第 418 场周赛 Q2 tags: - 深度优先搜索 - 广度优先搜索 diff --git a/solution/3300-3399/3310.Remove Methods From Project/README_EN.md b/solution/3300-3399/3310.Remove Methods From Project/README_EN.md index b7f0307a4c677..5990a503ec0d3 100644 --- a/solution/3300-3399/3310.Remove Methods From Project/README_EN.md +++ b/solution/3300-3399/3310.Remove Methods From Project/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3310.Remove%20Methods%20From%20Project/README_EN.md +rating: 1710 +source: Weekly Contest 418 Q2 tags: - Depth-First Search - Breadth-First Search diff --git a/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README.md b/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README.md index 72b6215ee8568..c6c61c8b3da6e 100644 --- a/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README.md +++ b/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3311.Construct%202D%20Grid%20Matching%20Graph%20Layout/README.md +rating: 2664 +source: 第 418 场周赛 Q3 tags: - 图 - 数组 diff --git a/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README_EN.md b/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README_EN.md index 761a653e8bd97..08a84d1a5e873 100644 --- a/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README_EN.md +++ b/solution/3300-3399/3311.Construct 2D Grid Matching Graph Layout/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3311.Construct%202D%20Grid%20Matching%20Graph%20Layout/README_EN.md +rating: 2664 +source: Weekly Contest 418 Q3 tags: - Graph - Array diff --git a/solution/3300-3399/3312.Sorted GCD Pair Queries/README.md b/solution/3300-3399/3312.Sorted GCD Pair Queries/README.md index 9c5afe8ece063..7220f5c2c4e71 100644 --- a/solution/3300-3399/3312.Sorted GCD Pair Queries/README.md +++ b/solution/3300-3399/3312.Sorted GCD Pair Queries/README.md @@ -2,6 +2,8 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3312.Sorted%20GCD%20Pair%20Queries/README.md +rating: 2532 +source: 第 418 场周赛 Q4 tags: - 数组 - 哈希表 diff --git a/solution/3300-3399/3312.Sorted GCD Pair Queries/README_EN.md b/solution/3300-3399/3312.Sorted GCD Pair Queries/README_EN.md index 2f780e208ad83..7fe6cb1fac594 100644 --- a/solution/3300-3399/3312.Sorted GCD Pair Queries/README_EN.md +++ b/solution/3300-3399/3312.Sorted GCD Pair Queries/README_EN.md @@ -2,6 +2,8 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3312.Sorted%20GCD%20Pair%20Queries/README_EN.md +rating: 2532 +source: Weekly Contest 418 Q4 tags: - Array - Hash Table diff --git a/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README.md b/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README.md index 6b5475e0b1d20..fea3aaaafc814 100644 --- a/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README.md +++ b/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README.md +tags: + - 位运算 + - 数组 --- <!-- problem:start --> diff --git a/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README_EN.md b/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README_EN.md index aeb5b42af38ba..c133b365167c9 100644 --- a/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README_EN.md +++ b/solution/3300-3399/3314.Construct the Minimum Bitwise Array I/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README_EN.md +tags: + - Bit Manipulation + - Array --- <!-- problem:start --> diff --git a/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README.md b/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README.md index c4cdffe40a742..1fffa7ba785e1 100644 --- a/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README.md +++ b/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README.md +tags: + - 位运算 + - 数组 --- <!-- problem:start --> diff --git a/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md b/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md index f9ae16599b691..da4aa0cd7cce0 100644 --- a/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md +++ b/solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README_EN.md +tags: + - Bit Manipulation + - Array --- <!-- problem:start --> diff --git a/solution/3300-3399/3316.Find Maximum Removals From Source String/README.md b/solution/3300-3399/3316.Find Maximum Removals From Source String/README.md index 522a5c9ad1b83..5e02847924663 100644 --- a/solution/3300-3399/3316.Find Maximum Removals From Source String/README.md +++ b/solution/3300-3399/3316.Find Maximum Removals From Source String/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README.md +tags: + - 数组 + - 哈希表 + - 双指针 + - 字符串 + - 动态规划 --- <!-- problem:start --> diff --git a/solution/3300-3399/3316.Find Maximum Removals From Source String/README_EN.md b/solution/3300-3399/3316.Find Maximum Removals From Source String/README_EN.md index 766fa13dabc9f..243eb8f5a759b 100644 --- a/solution/3300-3399/3316.Find Maximum Removals From Source String/README_EN.md +++ b/solution/3300-3399/3316.Find Maximum Removals From Source String/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README_EN.md +tags: + - Array + - Hash Table + - Two Pointers + - String + - Dynamic Programming --- <!-- problem:start --> diff --git a/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README.md b/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README.md index 389826005dcf0..4e4dbed8681eb 100644 --- a/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README.md +++ b/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README.md @@ -2,6 +2,10 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README.md +tags: + - 数学 + - 动态规划 + - 组合数学 --- <!-- problem:start --> diff --git a/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README_EN.md b/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README_EN.md index 1616c8a6e59bc..9b2ce3b1998ff 100644 --- a/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README_EN.md +++ b/solution/3300-3399/3317.Find the Number of Possible Ways for an Event/README_EN.md @@ -2,6 +2,10 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README_EN.md +tags: + - Math + - Dynamic Programming + - Combinatorics --- <!-- problem:start --> diff --git a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README.md b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README.md index 2ca2e860a26df..0bd6560e29e19 100644 --- a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README.md +++ b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README.md @@ -2,6 +2,11 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README.md +tags: + - 数组 + - 哈希表 + - 滑动窗口 + - 堆(优先队列) --- <!-- problem:start --> diff --git a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README_EN.md b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README_EN.md index 62143c5d02775..e6363631c8679 100644 --- a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README_EN.md +++ b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/README_EN.md @@ -2,6 +2,11 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README_EN.md +tags: + - Array + - Hash Table + - Sliding Window + - Heap (Priority Queue) --- <!-- problem:start --> diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README.md b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README.md index 9334a995525d3..c576073612048 100644 --- a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README.md +++ b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README.md @@ -2,6 +2,11 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README.md +tags: + - 树 + - 深度优先搜索 + - 二叉树 + - 排序 --- <!-- problem:start --> @@ -33,9 +38,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K- <p><strong>解释:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image.jpg" style="width: 300px; height: 175px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmpresl95rp-1.png" style="width: 400px; height: 173px;" /></p> -<p>完美二叉子树的根节点在图中以黑色突出显示。它们的大小按降序排列为 <code>[3, 3, 1, 1, 1, 1, 1, 1]</code>。<br /> +<p>完美二叉子树的根节点在图中以黑色突出显示。它们的大小按非递增顺序排列为 <code>[3, 3, 1, 1, 1, 1, 1, 1]</code>。<br /> 第 <code>2</code> 大的完美二叉子树的大小是 3。</p> </div> @@ -48,9 +53,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K- <p><strong>解释:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image1.jpg" style="width: 300px; height: 149px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmp_s508x9e-1.png" style="width: 300px; height: 189px;" /></p> -<p>完美二叉子树的大小按降序排列为 <code>[7, 3, 3, 1, 1, 1, 1]</code>。最大的完美二叉子树的大小是 7。</p> +<p>完美二叉子树的大小按非递增顺序排列为 <code>[7, 3, 3, 1, 1, 1, 1]</code>。最大的完美二叉子树的大小是 7。</p> </div> <p><strong class="example">示例 3:</strong></p> @@ -62,9 +67,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K- <p><strong>解释:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image4.jpg" style="width: 150px; height: 130px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmp74xnmpj4-1.png" style="width: 250px; height: 225px;" /></p> -<p>完美二叉子树的大小按降序排列为 <code>[1, 1]</code>。完美二叉子树的数量少于 3。</p> +<p>完美二叉子树的大小按非递增顺序排列为 <code>[1, 1]</code>。完美二叉子树的数量少于 3。</p> </div> <p> </p> diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README_EN.md b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README_EN.md index b30257addfb7d..1c4353ef2d369 100644 --- a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README_EN.md +++ b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/README_EN.md @@ -2,6 +2,11 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README_EN.md +tags: + - Tree + - Depth-First Search + - Binary Tree + - Sorting --- <!-- problem:start --> @@ -30,9 +35,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3319.K- <p><strong>Explanation:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image.jpg" style="width: 300px; height: 175px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmpresl95rp-1.png" style="width: 400px; height: 173px;" /></p> -<p>The roots of the perfect binary subtrees are highlighted in black. Their sizes, in decreasing order are <code>[3, 3, 1, 1, 1, 1, 1, 1]</code>.<br /> +<p>The roots of the perfect binary subtrees are highlighted in black. Their sizes, in non-increasing order are <code>[3, 3, 1, 1, 1, 1, 1, 1]</code>.<br /> The <code>2<sup>nd</sup></code> largest size is 3.</p> </div> @@ -45,9 +50,9 @@ The <code>2<sup>nd</sup></code> largest size is 3.</p> <p><strong>Explanation:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image1.jpg" style="width: 300px; height: 149px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmp_s508x9e-1.png" style="width: 300px; height: 189px;" /></p> -<p>The sizes of the perfect binary subtrees in decreasing order are <code>[7, 3, 3, 1, 1, 1, 1]</code>. The size of the largest perfect binary subtree is 7.</p> +<p>The sizes of the perfect binary subtrees in non-increasing order are <code>[7, 3, 3, 1, 1, 1, 1]</code>. The size of the largest perfect binary subtree is 7.</p> </div> <p><strong class="example">Example 3:</strong></p> @@ -59,9 +64,9 @@ The <code>2<sup>nd</sup></code> largest size is 3.</p> <p><strong>Explanation:</strong></p> -<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/image4.jpg" style="width: 150px; height: 130px;" /></p> +<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/images/tmp74xnmpj4-1.png" style="width: 250px; height: 225px;" /></p> -<p>The sizes of the perfect binary subtrees in decreasing order are <code>[1, 1]</code>. There are fewer than 3 perfect binary subtrees.</p> +<p>The sizes of the perfect binary subtrees in non-increasing order are <code>[1, 1]</code>. There are fewer than 3 perfect binary subtrees.</p> </div> <p> </p> diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image.jpg b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image.jpg deleted file mode 100644 index 3a74b5a5d2644..0000000000000 Binary files a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image.jpg and /dev/null differ diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image1.jpg b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image1.jpg deleted file mode 100644 index 1d7ef9cf0523a..0000000000000 Binary files a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image1.jpg and /dev/null differ diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image4.jpg b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image4.jpg deleted file mode 100644 index f8c9987f20879..0000000000000 Binary files a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/image4.jpg and /dev/null differ diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp74xnmpj4-1.png b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp74xnmpj4-1.png new file mode 100644 index 0000000000000..1bab1d327d446 Binary files /dev/null and b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp74xnmpj4-1.png differ diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp_s508x9e-1.png b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp_s508x9e-1.png new file mode 100644 index 0000000000000..739f4139975e9 Binary files /dev/null and b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmp_s508x9e-1.png differ diff --git a/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmpresl95rp-1.png b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmpresl95rp-1.png new file mode 100644 index 0000000000000..11e619452d358 Binary files /dev/null and b/solution/3300-3399/3319.K-th Largest Perfect Subtree Size in Binary Tree/images/tmpresl95rp-1.png differ diff --git a/solution/3300-3399/3320.Count The Number of Winning Sequences/README.md b/solution/3300-3399/3320.Count The Number of Winning Sequences/README.md index 93c61e0a55700..5fb78f3564b47 100644 --- a/solution/3300-3399/3320.Count The Number of Winning Sequences/README.md +++ b/solution/3300-3399/3320.Count The Number of Winning Sequences/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README.md +tags: + - 字符串 + - 动态规划 --- <!-- problem:start --> diff --git a/solution/3300-3399/3320.Count The Number of Winning Sequences/README_EN.md b/solution/3300-3399/3320.Count The Number of Winning Sequences/README_EN.md index a8aeb66e0cebb..1972b87a463ca 100644 --- a/solution/3300-3399/3320.Count The Number of Winning Sequences/README_EN.md +++ b/solution/3300-3399/3320.Count The Number of Winning Sequences/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README_EN.md +tags: + - String + - Dynamic Programming --- <!-- problem:start --> @@ -67,7 +70,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3320.Co <ul> <li><code>1 <= s.length <= 1000</code></li> - <li><code>s[i]</code> is either <code>'F'</code>, <code>'W'</code>, or <code>'E'</code>.</li> + <li><code>s[i]</code> is one of <code>'F'</code>, <code>'W'</code>, or <code>'E'</code>.</li> </ul> <!-- description:end --> diff --git a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README.md b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README.md index 1679e35c67535..817f046cdbd9d 100644 --- a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README.md +++ b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README.md @@ -2,6 +2,11 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README.md +tags: + - 数组 + - 哈希表 + - 滑动窗口 + - 堆(优先队列) --- <!-- problem:start --> diff --git a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README_EN.md b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README_EN.md index 9701adc4cf9c9..3ef85e8fa552e 100644 --- a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README_EN.md +++ b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/README_EN.md @@ -2,6 +2,11 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README_EN.md +tags: + - Array + - Hash Table + - Sliding Window + - Heap (Priority Queue) --- <!-- problem:start --> diff --git a/solution/3300-3399/3322.Premier League Table Ranking III/README_EN.md b/solution/3300-3399/3322.Premier League Table Ranking III/README_EN.md index cfc805ef73eed..e586d86da3e4f 100644 --- a/solution/3300-3399/3322.Premier League Table Ranking III/README_EN.md +++ b/solution/3300-3399/3322.Premier League Table Ranking III/README_EN.md @@ -85,20 +85,20 @@ This table contains season id, team id, team name, matches played, wins, draws, <p><strong>Output:</strong></p> <pre> -+------------+---------+-------------------+--------+-----------------+------+ -| season_id | team_id | team_name | points | goal_difference | rank | -+------------+---------+-------------------+--------+-----------------+------+ -| 2021 | 1 | Manchester City | 93 | 73 | 1 | -| 2021 | 2 | Liverpool | 92 | 68 | 2 | -| 2021 | 3 | Chelsea | 74 | 43 | 3 | -| 2021 | 4 | Tottenham | 71 | 29 | 4 | -| 2021 | 5 | Arsenal | 69 | 13 | 5 | -| 2022 | 1 | Manchester City | 89 | 61 | 1 | -| 2022 | 2 | Arsenal | 84 | 45 | 2 | -| 2022 | 3 | Manchester United | 75 | 15 | 3 | -| 2022 | 4 | Newcastle | 71 | 35 | 4 | -| 2022 | 5 | Liverpool | 67 | 28 | 5 | -+------------+---------+-------------------+--------+-----------------+------+ ++------------+---------+-------------------+--------+-----------------+----------+ +| season_id | team_id | team_name | points | goal_difference | position | ++------------+---------+-------------------+--------+-----------------+----------+ +| 2021 | 1 | Manchester City | 93 | 73 | 1 | +| 2021 | 2 | Liverpool | 92 | 68 | 2 | +| 2021 | 3 | Chelsea | 74 | 43 | 3 | +| 2021 | 4 | Tottenham | 71 | 29 | 4 | +| 2021 | 5 | Arsenal | 69 | 13 | 5 | +| 2022 | 1 | Manchester City | 89 | 61 | 1 | +| 2022 | 2 | Arsenal | 84 | 45 | 2 | +| 2022 | 3 | Manchester United | 75 | 15 | 3 | +| 2022 | 4 | Newcastle | 71 | 35 | 4 | +| 2022 | 5 | Liverpool | 67 | 28 | 5 | ++------------+---------+-------------------+--------+-----------------+----------+ </pre> <p><strong>Explanation:</strong></p> diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README.md b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README.md new file mode 100644 index 0000000000000..040d357a4aded --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README.md @@ -0,0 +1,243 @@ +--- +comments: true +difficulty: 中等 +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README.md +--- + +<!-- problem:start --> + +# [3323. 通过插入区间最小化连通组 🔒](https://leetcode.cn/problems/minimize-connected-groups-by-inserting-interval) + +[English Version](/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README_EN.md) + +## 题目描述 + +<!-- description:start --> + +<p>给定一个 2 维数组 <code>intervals</code>,其中 <code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> 表示区间 <code>i</code> 的开头和结尾。另外还给定一个整数 <code>k</code>。</p> + +<p>你必须向数组添加 <strong>恰好一个</strong> 新的区间 <code>[start<sub>new</sub>, end<sub>new</sub>]</code> 使得:</p> + +<ul> + <li>新区间的长度,<code>end<sub>new</sub> - start<sub>new</sub></code> 最多为 <code>k</code>。</li> + <li>在添加之后,<code>intervals</code> 中 <strong>连通组</strong> 的数量 <strong>最少</strong>。</li> +</ul> + +<p>区间的 <strong>连通组</strong> 是一起覆盖了从最小点到最大点的连续范围,中间没有间隙的区间的最大集合。下面是一些例子:</p> + +<ul> + <li>区间组 <code>[[1, 2], [2, 5], [3, 3]]</code> 是连通的,因为它们一起覆盖了 1 到 5 的范围,中间没有任何间隔。</li> + <li>然而,区间组 <code>[[1, 2], [3, 4]]</code> 不是连通的,因为 <code>(2, 3)</code> 段没有被覆盖。</li> +</ul> + +<p>返回在添加 <strong>恰好一个</strong> 新区间到数组后连通组的 <strong>最小</strong> 数量。</p> + +<p> </p> + +<p><strong class="example">示例 1:</strong></p> + +<div class="example-block"> +<p><span class="example-io"><b>输入:</b>intervals = [[1,3],[5,6],[8,10]], k = 3</span></p> + +<p><span class="example-io"><b>输出:</b>2</span></p> + +<p><strong>解释:</strong></p> + +<p>在添加区间 <code>[3, 5]</code> 后,我们有两个连通组:<code>[[1, 3], [3, 5], [5, 6]]</code> 和 <code>[[8, 10]]</code>。</p> +</div> + +<p><strong class="example">示例 2:</strong></p> + +<div class="example-block"> +<p><span class="example-io"><b>输入:</b>intervals = [[5,10],[1,1],[3,3]], k = 1</span></p> + +<p><span class="example-io"><b>输出:</b>3</span></p> + +<p><strong>解释:</strong></p> + +<p>在添加区间 <code>[1, 1]</code> 后,我们有三个连通组:<code>[[1, 1], [1, 1]]</code>,<code>[[3, 3]]</code>,和 <code>[[5, 10]]</code>。</p> +</div> + +<p> </p> + +<p><strong>提示:</strong></p> + +<ul> + <li><code>1 <= intervals.length <= 10<sup>5</sup></code></li> + <li><code>intervals[i] == [start<sub>i</sub>, end<sub>i</sub>]</code></li> + <li><code>1 <= start<sub>i</sub> <= end<sub>i</sub> <= 10<sup>9</sup></code></li> + <li><code>1 <= k <= 10<sup>9</sup></code></li> +</ul> + +<!-- description:end --> + +## 解法 + +<!-- solution:start --> + +### 方法一:排序 + 二分查找 + +首先,我们对给定的区间集合 $\textit{intervals}$ 按照区间的左端点进行排序,然后合并所有相交的区间,得到一个新的区间集合 $\textit{merged}$。 + +那么我们可以将初始答案设为 $\textit{merged}$ 的长度。 + +接下来,我们枚举 $\textit{merged}$ 中的每一个区间 $[\_, e]$,我们可以通过二分查找,在 $\textit{merged}$ 中找到第一个左端点大于等于 $e + k + 1$ 的区间,设其下标为 $j$,那么我们可以将答案更新,即 $\textit{ans} = \min(\textit{ans}, |\textit{merged}| - (j - i - 1))$。 + +最终,我们返回答案 $\textit{ans}$ 即可。 + +时间复杂度 $O(n \times \log n)$,空间复杂度 $O(n)$。其中 $n$ 为区间的数量。 + +<!-- tabs:start --> + +#### Python3 + +```python +class Solution: + def minConnectedGroups(self, intervals: List[List[int]], k: int) -> int: + intervals.sort() + merged = [intervals[0]] + for s, e in intervals[1:]: + if merged[-1][1] < s: + merged.append([s, e]) + else: + merged[-1][1] = max(merged[-1][1], e) + ans = len(merged) + for i, (_, e) in enumerate(merged): + j = bisect_left(merged, [e + k + 1, 0]) + ans = min(ans, len(merged) - (j - i - 1)) + return ans +``` + +#### Java + +```java +class Solution { + public int minConnectedGroups(int[][] intervals, int k) { + Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0])); + List<int[]> merged = new ArrayList<>(); + merged.add(intervals[0]); + for (int i = 1; i < intervals.length; i++) { + int[] interval = intervals[i]; + int[] last = merged.get(merged.size() - 1); + if (last[1] < interval[0]) { + merged.add(interval); + } else { + last[1] = Math.max(last[1], interval[1]); + } + } + + int ans = merged.size(); + for (int i = 0; i < merged.size(); i++) { + int[] interval = merged.get(i); + int j = binarySearch(merged, interval[1] + k + 1); + ans = Math.min(ans, merged.size() - (j - i - 1)); + } + + return ans; + } + + private int binarySearch(List<int[]> nums, int x) { + int l = 0, r = nums.size(); + while (l < r) { + int mid = (l + r) >> 1; + if (nums.get(mid)[0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + int minConnectedGroups(vector<vector<int>>& intervals, int k) { + sort(intervals.begin(), intervals.end()); + vector<vector<int>> merged; + for (const auto& interval : intervals) { + int s = interval[0], e = interval[1]; + if (merged.empty() || merged.back()[1] < s) { + merged.emplace_back(interval); + } else { + merged.back()[1] = max(merged.back()[1], e); + } + } + int ans = merged.size(); + for (int i = 0; i < merged.size(); ++i) { + auto& interval = merged[i]; + int j = lower_bound(merged.begin(), merged.end(), vector<int>{interval[1] + k + 1, 0}) - merged.begin(); + ans = min(ans, (int) merged.size() - (j - i - 1)); + } + return ans; + } +}; +``` + +#### Go + +```go +func minConnectedGroups(intervals [][]int, k int) int { + sort.Slice(intervals, func(i, j int) bool { return intervals[i][0] < intervals[j][0] }) + merged := [][]int{} + for _, interval := range intervals { + s, e := interval[0], interval[1] + if len(merged) == 0 || merged[len(merged)-1][1] < s { + merged = append(merged, interval) + } else { + merged[len(merged)-1][1] = max(merged[len(merged)-1][1], e) + } + } + ans := len(merged) + for i, interval := range merged { + j := sort.Search(len(merged), func(j int) bool { return merged[j][0] >= interval[1]+k+1 }) + ans = min(ans, len(merged)-(j-i-1)) + } + return ans +} +``` + +#### TypeScript + +```ts +function minConnectedGroups(intervals: number[][], k: number): number { + intervals.sort((a, b) => a[0] - b[0]); + const merged: number[][] = []; + for (const interval of intervals) { + const [s, e] = interval; + if (merged.length === 0 || merged.at(-1)![1] < s) { + merged.push(interval); + } else { + merged.at(-1)![1] = Math.max(merged.at(-1)![1], e); + } + } + const search = (x: number): number => { + let [l, r] = [0, merged.length]; + while (l < r) { + const mid = (l + r) >> 1; + if (merged[mid][0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + }; + let ans = merged.length; + for (let i = 0; i < merged.length; ++i) { + const j = search(merged[i][1] + k + 1); + ans = Math.min(ans, merged.length - (j - i - 1)); + } + return ans; +} +``` + +<!-- tabs:end --> + +<!-- solution:end --> + +<!-- problem:end --> diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README_EN.md b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README_EN.md new file mode 100644 index 0000000000000..4da147c0ad85a --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/README_EN.md @@ -0,0 +1,241 @@ +--- +comments: true +difficulty: Medium +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README_EN.md +--- + +<!-- problem:start --> + +# [3323. Minimize Connected Groups by Inserting Interval 🔒](https://leetcode.com/problems/minimize-connected-groups-by-inserting-interval) + +[中文文档](/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README.md) + +## Description + +<!-- description:start --> + +<p>You are given a 2D array <code>intervals</code>, where <code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> represents the start and the end of interval <code>i</code>. You are also given an integer <code>k</code>.</p> + +<p>You must add <strong>exactly one</strong> new interval <code>[start<sub>new</sub>, end<sub>new</sub>]</code> to the array such that:</p> + +<ul> + <li>The length of the new interval, <code>end<sub>new</sub> - start<sub>new</sub></code>, is at most <code>k</code>.</li> + <li>After adding, the number of <strong>connected groups</strong> in <code>intervals</code> is <strong>minimized</strong>.</li> +</ul> + +<p>A <strong>connected group</strong> of intervals is a maximal collection of intervals that, when considered together, cover a continuous range from the smallest point to the largest point with no gaps between them. Here are some examples:</p> + +<ul> + <li>A group of intervals <code>[[1, 2], [2, 5], [3, 3]]</code> is connected because together they cover the range from 1 to 5 without any gaps.</li> + <li>However, a group of intervals <code>[[1, 2], [3, 4]]</code> is not connected because the segment <code>(2, 3)</code> is not covered.</li> +</ul> + +<p>Return the <strong>minimum</strong> number of connected groups after adding <strong>exactly one</strong> new interval to the array.</p> + +<p> </p> +<p><strong class="example">Example 1:</strong></p> + +<div class="example-block"> +<p><strong>Input:</strong> <span class="example-io">intervals = [[1,3],[5,6],[8,10]], k = 3</span></p> + +<p><strong>Output:</strong> <span class="example-io">2</span></p> + +<p><strong>Explanation:</strong></p> + +<p>After adding the interval <code>[3, 5]</code>, we have two connected groups: <code>[[1, 3], [3, 5], [5, 6]]</code> and <code>[[8, 10]]</code>.</p> +</div> + +<p><strong class="example">Example 2:</strong></p> + +<div class="example-block"> +<p><strong>Input:</strong> <span class="example-io">intervals = [[5,10],[1,1],[3,3]], k = 1</span></p> + +<p><strong>Output:</strong> <span class="example-io">3</span></p> + +<p><strong>Explanation:</strong></p> + +<p>After adding the interval <code>[1, 1]</code>, we have three connected groups: <code>[[1, 1], [1, 1]]</code>, <code>[[3, 3]]</code>, and <code>[[5, 10]]</code>.</p> +</div> + +<p> </p> +<p><strong>Constraints:</strong></p> + +<ul> + <li><code>1 <= intervals.length <= 10<sup>5</sup></code></li> + <li><code>intervals[i] == [start<sub>i</sub>, end<sub>i</sub>]</code></li> + <li><code>1 <= start<sub>i</sub> <= end<sub>i</sub> <= 10<sup>9</sup></code></li> + <li><code>1 <= k <= 10<sup>9</sup></code></li> +</ul> + +<!-- description:end --> + +## Solutions + +<!-- solution:start --> + +### Solution 1: Sorting + Binary Search + +First, we sort the given set of intervals $\textit{intervals}$ by their left endpoints, then merge all overlapping intervals to obtain a new set of intervals $\textit{merged}$. + +We can then set the initial answer to the length of $\textit{merged}$. + +Next, we enumerate each interval $[\_, e]$ in $\textit{merged}$. Using binary search, we find the first interval in $\textit{merged}$ whose left endpoint is greater than or equal to $e + k + 1$, and let its index be $j$. We can then update the answer as $\textit{ans} = \min(\textit{ans}, |\textit{merged}| - (j - i - 1))$. + +Finally, we return the answer $\textit{ans}$. + +The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. Here, $n$ is the number of intervals. + +<!-- tabs:start --> + +#### Python3 + +```python +class Solution: + def minConnectedGroups(self, intervals: List[List[int]], k: int) -> int: + intervals.sort() + merged = [intervals[0]] + for s, e in intervals[1:]: + if merged[-1][1] < s: + merged.append([s, e]) + else: + merged[-1][1] = max(merged[-1][1], e) + ans = len(merged) + for i, (_, e) in enumerate(merged): + j = bisect_left(merged, [e + k + 1, 0]) + ans = min(ans, len(merged) - (j - i - 1)) + return ans +``` + +#### Java + +```java +class Solution { + public int minConnectedGroups(int[][] intervals, int k) { + Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0])); + List<int[]> merged = new ArrayList<>(); + merged.add(intervals[0]); + for (int i = 1; i < intervals.length; i++) { + int[] interval = intervals[i]; + int[] last = merged.get(merged.size() - 1); + if (last[1] < interval[0]) { + merged.add(interval); + } else { + last[1] = Math.max(last[1], interval[1]); + } + } + + int ans = merged.size(); + for (int i = 0; i < merged.size(); i++) { + int[] interval = merged.get(i); + int j = binarySearch(merged, interval[1] + k + 1); + ans = Math.min(ans, merged.size() - (j - i - 1)); + } + + return ans; + } + + private int binarySearch(List<int[]> nums, int x) { + int l = 0, r = nums.size(); + while (l < r) { + int mid = (l + r) >> 1; + if (nums.get(mid)[0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + int minConnectedGroups(vector<vector<int>>& intervals, int k) { + sort(intervals.begin(), intervals.end()); + vector<vector<int>> merged; + for (const auto& interval : intervals) { + int s = interval[0], e = interval[1]; + if (merged.empty() || merged.back()[1] < s) { + merged.emplace_back(interval); + } else { + merged.back()[1] = max(merged.back()[1], e); + } + } + int ans = merged.size(); + for (int i = 0; i < merged.size(); ++i) { + auto& interval = merged[i]; + int j = lower_bound(merged.begin(), merged.end(), vector<int>{interval[1] + k + 1, 0}) - merged.begin(); + ans = min(ans, (int) merged.size() - (j - i - 1)); + } + return ans; + } +}; +``` + +#### Go + +```go +func minConnectedGroups(intervals [][]int, k int) int { + sort.Slice(intervals, func(i, j int) bool { return intervals[i][0] < intervals[j][0] }) + merged := [][]int{} + for _, interval := range intervals { + s, e := interval[0], interval[1] + if len(merged) == 0 || merged[len(merged)-1][1] < s { + merged = append(merged, interval) + } else { + merged[len(merged)-1][1] = max(merged[len(merged)-1][1], e) + } + } + ans := len(merged) + for i, interval := range merged { + j := sort.Search(len(merged), func(j int) bool { return merged[j][0] >= interval[1]+k+1 }) + ans = min(ans, len(merged)-(j-i-1)) + } + return ans +} +``` + +#### TypeScript + +```ts +function minConnectedGroups(intervals: number[][], k: number): number { + intervals.sort((a, b) => a[0] - b[0]); + const merged: number[][] = []; + for (const interval of intervals) { + const [s, e] = interval; + if (merged.length === 0 || merged.at(-1)![1] < s) { + merged.push(interval); + } else { + merged.at(-1)![1] = Math.max(merged.at(-1)![1], e); + } + } + const search = (x: number): number => { + let [l, r] = [0, merged.length]; + while (l < r) { + const mid = (l + r) >> 1; + if (merged[mid][0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + }; + let ans = merged.length; + for (let i = 0; i < merged.length; ++i) { + const j = search(merged[i][1] + k + 1); + ans = Math.min(ans, merged.length - (j - i - 1)); + } + return ans; +} +``` + +<!-- tabs:end --> + +<!-- solution:end --> + +<!-- problem:end --> diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.cpp b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.cpp new file mode 100644 index 0000000000000..5a854e49a76a8 --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int minConnectedGroups(vector<vector<int>>& intervals, int k) { + sort(intervals.begin(), intervals.end()); + vector<vector<int>> merged; + for (const auto& interval : intervals) { + int s = interval[0], e = interval[1]; + if (merged.empty() || merged.back()[1] < s) { + merged.emplace_back(interval); + } else { + merged.back()[1] = max(merged.back()[1], e); + } + } + int ans = merged.size(); + for (int i = 0; i < merged.size(); ++i) { + auto& interval = merged[i]; + int j = lower_bound(merged.begin(), merged.end(), vector<int>{interval[1] + k + 1, 0}) - merged.begin(); + ans = min(ans, (int) merged.size() - (j - i - 1)); + } + return ans; + } +}; diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.go b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.go new file mode 100644 index 0000000000000..cb74fe9c0e470 --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.go @@ -0,0 +1,18 @@ +func minConnectedGroups(intervals [][]int, k int) int { + sort.Slice(intervals, func(i, j int) bool { return intervals[i][0] < intervals[j][0] }) + merged := [][]int{} + for _, interval := range intervals { + s, e := interval[0], interval[1] + if len(merged) == 0 || merged[len(merged)-1][1] < s { + merged = append(merged, interval) + } else { + merged[len(merged)-1][1] = max(merged[len(merged)-1][1], e) + } + } + ans := len(merged) + for i, interval := range merged { + j := sort.Search(len(merged), func(j int) bool { return merged[j][0] >= interval[1]+k+1 }) + ans = min(ans, len(merged)-(j-i-1)) + } + return ans +} diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.java b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.java new file mode 100644 index 0000000000000..1f654399208ce --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.java @@ -0,0 +1,38 @@ +class Solution { + public int minConnectedGroups(int[][] intervals, int k) { + Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0])); + List<int[]> merged = new ArrayList<>(); + merged.add(intervals[0]); + for (int i = 1; i < intervals.length; i++) { + int[] interval = intervals[i]; + int[] last = merged.get(merged.size() - 1); + if (last[1] < interval[0]) { + merged.add(interval); + } else { + last[1] = Math.max(last[1], interval[1]); + } + } + + int ans = merged.size(); + for (int i = 0; i < merged.size(); i++) { + int[] interval = merged.get(i); + int j = binarySearch(merged, interval[1] + k + 1); + ans = Math.min(ans, merged.size() - (j - i - 1)); + } + + return ans; + } + + private int binarySearch(List<int[]> nums, int x) { + int l = 0, r = nums.size(); + while (l < r) { + int mid = (l + r) >> 1; + if (nums.get(mid)[0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + } +} diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.py b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.py new file mode 100644 index 0000000000000..1af54ca30a2cb --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.py @@ -0,0 +1,14 @@ +class Solution: + def minConnectedGroups(self, intervals: List[List[int]], k: int) -> int: + intervals.sort() + merged = [intervals[0]] + for s, e in intervals[1:]: + if merged[-1][1] < s: + merged.append([s, e]) + else: + merged[-1][1] = max(merged[-1][1], e) + ans = len(merged) + for i, (_, e) in enumerate(merged): + j = bisect_left(merged, [e + k + 1, 0]) + ans = min(ans, len(merged) - (j - i - 1)) + return ans diff --git a/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.ts b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.ts new file mode 100644 index 0000000000000..51ddafd0a7375 --- /dev/null +++ b/solution/3300-3399/3323.Minimize Connected Groups by Inserting Interval/Solution.ts @@ -0,0 +1,30 @@ +function minConnectedGroups(intervals: number[][], k: number): number { + intervals.sort((a, b) => a[0] - b[0]); + const merged: number[][] = []; + for (const interval of intervals) { + const [s, e] = interval; + if (merged.length === 0 || merged.at(-1)![1] < s) { + merged.push(interval); + } else { + merged.at(-1)![1] = Math.max(merged.at(-1)![1], e); + } + } + const search = (x: number): number => { + let [l, r] = [0, merged.length]; + while (l < r) { + const mid = (l + r) >> 1; + if (merged[mid][0] >= x) { + r = mid; + } else { + l = mid + 1; + } + } + return l; + }; + let ans = merged.length; + for (let i = 0; i < merged.length; ++i) { + const j = search(merged[i][1] + k + 1); + ans = Math.min(ans, merged.length - (j - i - 1)); + } + return ans; +} diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md index a35d091b26ad7..c396c38a3b2ad 100644 --- a/solution/DATABASE_README.md +++ b/solution/DATABASE_README.md @@ -297,7 +297,7 @@ | 3278 | [寻找数据科学家职位的候选人 II](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README.md) | `数据库` | 中等 | 🔒 | | 3293 | [计算产品最终价格](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README.md) | `数据库` | 中等 | 🔒 | | 3308 | [Find Top Performing Driver](/solution/3300-3399/3308.Find%20Top%20Performing%20Driver/README.md) | `数据库` | 中等 | 🔒 | -| 3322 | [英超积分榜排名 III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README.md) | | 中等 | 🔒 | +| 3322 | [英超积分榜排名 III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README.md) | `数据库` | 中等 | 🔒 | ## 版权 diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md index 6c3a747cc5d04..0ad562b350bea 100644 --- a/solution/DATABASE_README_EN.md +++ b/solution/DATABASE_README_EN.md @@ -295,7 +295,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on | 3278 | [Find Candidates for Data Scientist Position II](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README_EN.md) | `Database` | Medium | 🔒 | | 3293 | [Calculate Product Final Price](/solution/3200-3299/3293.Calculate%20Product%20Final%20Price/README_EN.md) | `Database` | Medium | 🔒 | | 3308 | [Find Top Performing Driver](/solution/3300-3399/3308.Find%20Top%20Performing%20Driver/README_EN.md) | `Database` | Medium | 🔒 | -| 3322 | [Premier League Table Ranking III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README_EN.md) | | Medium | 🔒 | +| 3322 | [Premier League Table Ranking III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README_EN.md) | `Database` | Medium | 🔒 | ## Copyright diff --git a/solution/README.md b/solution/README.md index 2850c846cca7d..3a2b94001ea6a 100644 --- a/solution/README.md +++ b/solution/README.md @@ -3324,15 +3324,16 @@ | 3311 | [构造符合图结构的二维矩阵](/solution/3300-3399/3311.Construct%202D%20Grid%20Matching%20Graph%20Layout/README.md) | `图`,`数组`,`哈希表`,`矩阵` | 困难 | 第 418 场周赛 | | 3312 | [查询排序后的最大公约数](/solution/3300-3399/3312.Sorted%20GCD%20Pair%20Queries/README.md) | `数组`,`哈希表`,`数学`,`二分查找`,`组合数学`,`计数`,`数论`,`前缀和` | 困难 | 第 418 场周赛 | | 3313 | [查找树中最后标记的节点](/solution/3300-3399/3313.Find%20the%20Last%20Marked%20Nodes%20in%20Tree/README.md) | `树`,`深度优先搜索` | 困难 | 🔒 | -| 3314 | [构造最小位运算数组 I](/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README.md) | | 简单 | 第 141 场双周赛 | -| 3315 | [构造最小位运算数组 II](/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README.md) | | 中等 | 第 141 场双周赛 | -| 3316 | [从原字符串里进行删除操作的最多次数](/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README.md) | | 中等 | 第 141 场双周赛 | -| 3317 | [安排活动的方案数](/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README.md) | | 困难 | 第 141 场双周赛 | -| 3318 | [计算子数组的 x-sum I](/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README.md) | | 简单 | 第 419 场周赛 | -| 3319 | [第 K 大的完美二叉子树的大小](/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README.md) | | 中等 | 第 419 场周赛 | -| 3320 | [统计能获胜的出招序列数](/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README.md) | | 困难 | 第 419 场周赛 | -| 3321 | [计算子数组的 x-sum II](/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README.md) | | 困难 | 第 419 场周赛 | -| 3322 | [英超积分榜排名 III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README.md) | | 中等 | 🔒 | +| 3314 | [构造最小位运算数组 I](/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README.md) | `位运算`,`数组` | 简单 | 第 141 场双周赛 | +| 3315 | [构造最小位运算数组 II](/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README.md) | `位运算`,`数组` | 中等 | 第 141 场双周赛 | +| 3316 | [从原字符串里进行删除操作的最多次数](/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README.md) | `数组`,`哈希表`,`双指针`,`字符串`,`动态规划` | 中等 | 第 141 场双周赛 | +| 3317 | [安排活动的方案数](/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README.md) | `数学`,`动态规划`,`组合数学` | 困难 | 第 141 场双周赛 | +| 3318 | [计算子数组的 x-sum I](/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README.md) | `数组`,`哈希表`,`滑动窗口`,`堆(优先队列)` | 简单 | 第 419 场周赛 | +| 3319 | [第 K 大的完美二叉子树的大小](/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README.md) | `树`,`深度优先搜索`,`二叉树`,`排序` | 中等 | 第 419 场周赛 | +| 3320 | [统计能获胜的出招序列数](/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README.md) | `字符串`,`动态规划` | 困难 | 第 419 场周赛 | +| 3321 | [计算子数组的 x-sum II](/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README.md) | `数组`,`哈希表`,`滑动窗口`,`堆(优先队列)` | 困难 | 第 419 场周赛 | +| 3322 | [英超积分榜排名 III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README.md) | `数据库` | 中等 | 🔒 | +| 3323 | [通过插入区间最小化连通组](/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README.md) | | 中等 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index b19bfd7fb70bf..43edbb4870228 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -3322,15 +3322,16 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on | 3311 | [Construct 2D Grid Matching Graph Layout](/solution/3300-3399/3311.Construct%202D%20Grid%20Matching%20Graph%20Layout/README_EN.md) | `Graph`,`Array`,`Hash Table`,`Matrix` | Hard | Weekly Contest 418 | | 3312 | [Sorted GCD Pair Queries](/solution/3300-3399/3312.Sorted%20GCD%20Pair%20Queries/README_EN.md) | `Array`,`Hash Table`,`Math`,`Binary Search`,`Combinatorics`,`Counting`,`Number Theory`,`Prefix Sum` | Hard | Weekly Contest 418 | | 3313 | [Find the Last Marked Nodes in Tree](/solution/3300-3399/3313.Find%20the%20Last%20Marked%20Nodes%20in%20Tree/README_EN.md) | `Tree`,`Depth-First Search` | Hard | 🔒 | -| 3314 | [Construct the Minimum Bitwise Array I](/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README_EN.md) | | Easy | Biweekly Contest 141 | -| 3315 | [Construct the Minimum Bitwise Array II](/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README_EN.md) | | Medium | Biweekly Contest 141 | -| 3316 | [Find Maximum Removals From Source String](/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README_EN.md) | | Medium | Biweekly Contest 141 | -| 3317 | [Find the Number of Possible Ways for an Event](/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README_EN.md) | | Hard | Biweekly Contest 141 | -| 3318 | [Find X-Sum of All K-Long Subarrays I](/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README_EN.md) | | Easy | Weekly Contest 419 | -| 3319 | [K-th Largest Perfect Subtree Size in Binary Tree](/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README_EN.md) | | Medium | Weekly Contest 419 | -| 3320 | [Count The Number of Winning Sequences](/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README_EN.md) | | Hard | Weekly Contest 419 | -| 3321 | [Find X-Sum of All K-Long Subarrays II](/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README_EN.md) | | Hard | Weekly Contest 419 | -| 3322 | [Premier League Table Ranking III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README_EN.md) | | Medium | 🔒 | +| 3314 | [Construct the Minimum Bitwise Array I](/solution/3300-3399/3314.Construct%20the%20Minimum%20Bitwise%20Array%20I/README_EN.md) | `Bit Manipulation`,`Array` | Easy | Biweekly Contest 141 | +| 3315 | [Construct the Minimum Bitwise Array II](/solution/3300-3399/3315.Construct%20the%20Minimum%20Bitwise%20Array%20II/README_EN.md) | `Bit Manipulation`,`Array` | Medium | Biweekly Contest 141 | +| 3316 | [Find Maximum Removals From Source String](/solution/3300-3399/3316.Find%20Maximum%20Removals%20From%20Source%20String/README_EN.md) | `Array`,`Hash Table`,`Two Pointers`,`String`,`Dynamic Programming` | Medium | Biweekly Contest 141 | +| 3317 | [Find the Number of Possible Ways for an Event](/solution/3300-3399/3317.Find%20the%20Number%20of%20Possible%20Ways%20for%20an%20Event/README_EN.md) | `Math`,`Dynamic Programming`,`Combinatorics` | Hard | Biweekly Contest 141 | +| 3318 | [Find X-Sum of All K-Long Subarrays I](/solution/3300-3399/3318.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20I/README_EN.md) | `Array`,`Hash Table`,`Sliding Window`,`Heap (Priority Queue)` | Easy | Weekly Contest 419 | +| 3319 | [K-th Largest Perfect Subtree Size in Binary Tree](/solution/3300-3399/3319.K-th%20Largest%20Perfect%20Subtree%20Size%20in%20Binary%20Tree/README_EN.md) | `Tree`,`Depth-First Search`,`Binary Tree`,`Sorting` | Medium | Weekly Contest 419 | +| 3320 | [Count The Number of Winning Sequences](/solution/3300-3399/3320.Count%20The%20Number%20of%20Winning%20Sequences/README_EN.md) | `String`,`Dynamic Programming` | Hard | Weekly Contest 419 | +| 3321 | [Find X-Sum of All K-Long Subarrays II](/solution/3300-3399/3321.Find%20X-Sum%20of%20All%20K-Long%20Subarrays%20II/README_EN.md) | `Array`,`Hash Table`,`Sliding Window`,`Heap (Priority Queue)` | Hard | Weekly Contest 419 | +| 3322 | [Premier League Table Ranking III](/solution/3300-3399/3322.Premier%20League%20Table%20Ranking%20III/README_EN.md) | `Database` | Medium | 🔒 | +| 3323 | [Minimize Connected Groups by Inserting Interval](/solution/3300-3399/3323.Minimize%20Connected%20Groups%20by%20Inserting%20Interval/README_EN.md) | | Medium | 🔒 | ## Copyright