From d423cc1a7f323845bc83c0b4ed39c96fa19cd241 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Thu, 16 Jan 2025 12:56:51 +0800 Subject: [PATCH 1/2] feat: add solutions to lc problem: No.3422 (#3957) No.3422.Minimum Operations to Make Subarray Elements Equal --- .../README.md | 49 ++++++++++++++++++- .../README_EN.md | 47 +++++++++++++++++- .../Solution.go | 46 +++++++++++++++++ 3 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/Solution.go diff --git a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md index 063c164ac9244..1be8c45c55821 100644 --- a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md +++ b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md @@ -72,7 +72,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3422.Mi ### 方法一:有序集合 -根据题目描述,我们需要找到一个长度为 $k$ 的子数组,通过最少的操作使得子数组中的所有元素相等,即我们需要找到一个长度为 $k$ 的子数组,使得子数组中所有元素变成这 $k$ 个元素的中位数所需的最少操作次数最小。 +根据题目描述,我们需要找到一个长度为 $k$ 的子数组,通过最少的操作使得子数组中的所有元素相等,即我们需要找到一个长度为 $k$ 的子数组,使得子数组中所有元素变成这 $k$ 个元素的中位数所需的操作次数最小。 我们可以使用两个有序集合 $l$ 和 $r$ 分别维护 $k$ 个元素的左右两部分,其中 $l$ 用于存储 $k$ 个元素中较小的一部分,$r$ 用于存储 $k$ 个元素中较大的一部分,并且 $l$ 的元素个数要么等于 $r$ 的元素个数,要么比 $r$ 的元素个数少一个,这样 $r$ 的最小值就是 $k$ 个元素中的中位数。 @@ -214,7 +214,52 @@ public: #### Go ```go - +func minOperations(nums []int, k int) int64 { + l := redblacktree.New[int, int]() + r := redblacktree.New[int, int]() + merge := func(st *redblacktree.Tree[int, int], x, v int) { + c, _ := st.Get(x) + if c+v == 0 { + st.Remove(x) + } else { + st.Put(x, c+v) + } + } + var s1, s2, sz1, sz2 int + ans := math.MaxInt64 + for i, x := range nums { + merge(l, x, 1) + s1 += x + y := l.Right().Key + merge(l, y, -1) + s1 -= y + merge(r, y, 1) + s2 += y + sz2++ + if sz2-sz1 > 1 { + y = r.Left().Key + merge(r, y, -1) + s2 -= y + sz2-- + merge(l, y, 1) + s1 += y + sz1++ + } + if j := i - k + 1; j >= 0 { + ans = min(ans, s2-r.Left().Key*sz2+r.Left().Key*sz1-s1) + if _, ok := r.Get(nums[j]); ok { + merge(r, nums[j], -1) + s2 -= nums[j] + sz2-- + } else { + merge(l, nums[j], -1) + s1 -= nums[j] + sz1-- + } + } + } + return int64(ans) +} ``` diff --git a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README_EN.md b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README_EN.md index 4b0ce044bf85b..e95fefe8efd8c 100644 --- a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README_EN.md +++ b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README_EN.md @@ -214,7 +214,52 @@ public: #### Go ```go - +func minOperations(nums []int, k int) int64 { + l := redblacktree.New[int, int]() + r := redblacktree.New[int, int]() + merge := func(st *redblacktree.Tree[int, int], x, v int) { + c, _ := st.Get(x) + if c+v == 0 { + st.Remove(x) + } else { + st.Put(x, c+v) + } + } + var s1, s2, sz1, sz2 int + ans := math.MaxInt64 + for i, x := range nums { + merge(l, x, 1) + s1 += x + y := l.Right().Key + merge(l, y, -1) + s1 -= y + merge(r, y, 1) + s2 += y + sz2++ + if sz2-sz1 > 1 { + y = r.Left().Key + merge(r, y, -1) + s2 -= y + sz2-- + merge(l, y, 1) + s1 += y + sz1++ + } + if j := i - k + 1; j >= 0 { + ans = min(ans, s2-r.Left().Key*sz2+r.Left().Key*sz1-s1) + if _, ok := r.Get(nums[j]); ok { + merge(r, nums[j], -1) + s2 -= nums[j] + sz2-- + } else { + merge(l, nums[j], -1) + s1 -= nums[j] + sz1-- + } + } + } + return int64(ans) +} ``` diff --git a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/Solution.go b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/Solution.go new file mode 100644 index 0000000000000..83288acc361bb --- /dev/null +++ b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/Solution.go @@ -0,0 +1,46 @@ +func minOperations(nums []int, k int) int64 { + l := redblacktree.New[int, int]() + r := redblacktree.New[int, int]() + merge := func(st *redblacktree.Tree[int, int], x, v int) { + c, _ := st.Get(x) + if c+v == 0 { + st.Remove(x) + } else { + st.Put(x, c+v) + } + } + var s1, s2, sz1, sz2 int + ans := math.MaxInt64 + for i, x := range nums { + merge(l, x, 1) + s1 += x + y := l.Right().Key + merge(l, y, -1) + s1 -= y + merge(r, y, 1) + s2 += y + sz2++ + if sz2-sz1 > 1 { + y = r.Left().Key + merge(r, y, -1) + s2 -= y + sz2-- + merge(l, y, 1) + s1 += y + sz1++ + } + if j := i - k + 1; j >= 0 { + ans = min(ans, s2-r.Left().Key*sz2+r.Left().Key*sz1-s1) + if _, ok := r.Get(nums[j]); ok { + merge(r, nums[j], -1) + s2 -= nums[j] + sz2-- + } else { + merge(l, nums[j], -1) + s1 -= nums[j] + sz1-- + } + } + } + return int64(ans) +} From 0603fe494c62cfb983776910d1e9f94af215e132 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Thu, 16 Jan 2025 15:11:30 +0800 Subject: [PATCH 2/2] chore: remove unnecessary import statements (#3958) --- .../README.md" | 3 --- .../Solution.py" | 3 --- .../README.md" | 6 ----- .../Solution.java" | 5 +--- .../Solution.py" | 3 --- .../README.md" | 3 --- .../Solution2.py" | 3 --- .../README.md" | 3 --- .../Solution.py" | 2 -- .../0220.Contains Duplicate III/README.md | 3 --- .../0220.Contains Duplicate III/README_EN.md | 3 --- .../0220.Contains Duplicate III/Solution.py | 3 --- .../README.md | 2 -- .../README_EN.md | 2 -- .../Solution.java | 4 +-- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../0480.Sliding Window Median/README.md | 3 --- .../0480.Sliding Window Median/README_EN.md | 5 +--- .../0480.Sliding Window Median/Solution2.py | 3 --- solution/0700-0799/0716.Max Stack/README.md | 3 --- .../0700-0799/0716.Max Stack/README_EN.md | 3 --- solution/0700-0799/0716.Max Stack/Solution.py | 3 --- .../0700-0799/0729.My Calendar I/README.md | 3 --- .../0700-0799/0729.My Calendar I/README_EN.md | 3 --- .../0700-0799/0729.My Calendar I/Solution.py | 3 --- .../0700-0799/0731.My Calendar II/README.md | 3 --- .../0731.My Calendar II/README_EN.md | 9 +++---- .../0700-0799/0731.My Calendar II/Solution.py | 3 --- .../0846.Hand of Straights/README.md | 3 --- .../0846.Hand of Straights/README_EN.md | 3 --- .../0846.Hand of Straights/Solution2.py | 3 --- solution/0800-0899/0855.Exam Room/README.md | 3 --- .../0800-0899/0855.Exam Room/README_EN.md | 3 --- solution/0800-0899/0855.Exam Room/Solution.py | 3 --- .../0900-0999/0975.Odd Even Jump/README.md | 3 --- .../0900-0999/0975.Odd Even Jump/README_EN.md | 7 ++---- .../0900-0999/0975.Odd Even Jump/Solution.py | 3 --- .../README.md | 2 -- .../README_EN.md | 2 -- .../Solution.java | 4 +-- .../1172.Dinner Plate Stacks/README.md | 17 ++++++------- .../1172.Dinner Plate Stacks/README_EN.md | 19 ++++++-------- .../1172.Dinner Plate Stacks/Solution.py | 3 --- .../1244.Design A Leaderboard/README.md | 3 --- .../1244.Design A Leaderboard/README_EN.md | 3 --- .../1244.Design A Leaderboard/Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution2.py | 3 --- .../1348.Tweet Counts Per Frequency/README.md | 5 +--- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 11 +++----- .../README_EN.md | 13 ++++------ .../Solution.py | 3 --- .../1488.Avoid Flood in The City/README.md | 3 --- .../1488.Avoid Flood in The City/README_EN.md | 3 --- .../1488.Avoid Flood in The City/Solution.py | 3 --- .../README.md | 7 ++---- .../README_EN.md | 11 +++----- .../Solution.py | 3 --- .../1825.Finding MK Average/README.md | 8 +----- .../1825.Finding MK Average/README_EN.md | 8 +----- .../1825.Finding MK Average/Solution.py | 3 --- .../1825.Finding MK Average/Solution2.py | 3 --- .../1800-1899/1847.Closest Room/README.md | 3 --- .../1800-1899/1847.Closest Room/README_EN.md | 3 --- .../1800-1899/1847.Closest Room/Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../1912.Design Movie Rental System/README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution2.py | 3 --- .../2034.Stock Price Fluctuation/README.md | 3 --- .../2034.Stock Price Fluctuation/README_EN.md | 3 --- .../2034.Stock Price Fluctuation/Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 4 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 5 +--- .../Solution.py | 4 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../2454.Next Greater Element IV/README.md | 3 --- .../2454.Next Greater Element IV/README_EN.md | 3 --- .../2454.Next Greater Element IV/Solution.py | 3 --- .../2502.Design Memory Allocator/README.md | 3 --- .../2502.Design Memory Allocator/README_EN.md | 3 --- .../2502.Design Memory Allocator/Solution2.py | 3 --- .../2590.Design a Todo List/README.md | 25 ++++++++----------- .../2590.Design a Todo List/README_EN.md | 3 --- .../2590.Design a Todo List/Solution.py | 3 --- .../2612.Minimum Reverse Operations/README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../2653.Sliding Subarray Beauty/README.md | 3 --- .../2653.Sliding Subarray Beauty/README_EN.md | 5 +--- .../2600-2699/2659.Make Array Empty/README.md | 3 --- .../2659.Make Array Empty/README_EN.md | 3 --- .../2659.Make Array Empty/Solution.py | 3 --- .../2762.Continuous Subarrays/README.md | 3 --- .../2762.Continuous Subarrays/README_EN.md | 7 ++---- .../2762.Continuous Subarrays/Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 9 +++---- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 7 ++---- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution2.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 1 - .../README_EN.md | 1 - .../Solution3.java | 3 +-- .../README.md | 1 - .../README_EN.md | 1 - .../Solution.java | 3 +-- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../README.md | 3 --- .../README_EN.md | 3 --- .../Solution.py | 3 --- .../3408.Design Task Manager/README.md | 3 --- .../3408.Design Task Manager/README_EN.md | 3 --- .../3408.Design Task Manager/Solution.py | 4 --- 162 files changed, 64 insertions(+), 543 deletions(-) diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md" index 0a7445246a6a8..dd18ee74ba2eb 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/README.md" @@ -69,9 +69,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof2/%E5%89%91%E6%8C%87%2 #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool: s = SortedSet() diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py" "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py" index f7ec481ecdd5d..b0910923928e3 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 057. \345\200\274\345\222\214\344\270\213\346\240\207\344\271\213\345\267\256\351\203\275\345\234\250\347\273\231\345\256\232\347\232\204\350\214\203\345\233\264\345\206\205/Solution.py" @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class Solution: def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool: s = SortedSet() diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md" index a3933de14e03c..54acea6311fdc 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/README.md" @@ -65,9 +65,6 @@ MyCalendar.book(20, 30); // returns true ,第三个日程安排可以添加到 #### Python3 ```python -from sortedcontainers import SortedDict - - class MyCalendar: def __init__(self): self.sd = SortedDict() @@ -89,9 +86,6 @@ class MyCalendar: #### Java ```java -import java.util.Map; -import java.util.TreeMap; - class MyCalendar { private final TreeMap tm = new TreeMap<>(); diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java" index 3d04816dc4b2e..1bb41cffcc07f 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.java" @@ -1,6 +1,3 @@ -import java.util.Map; -import java.util.TreeMap; - class MyCalendar { private final TreeMap tm = new TreeMap<>(); @@ -25,4 +22,4 @@ public boolean book(int start, int end) { /** * Your MyCalendar object will be instantiated and called as such: MyCalendar * obj = new MyCalendar(); boolean param_1 = obj.book(start,end); - */ \ No newline at end of file + */ diff --git "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py" "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py" index a17617ab776e9..c04195aeb8688 100644 --- "a/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py" +++ "b/lcof2/\345\211\221\346\214\207 Offer II 058. \346\227\245\347\250\213\350\241\250/Solution.py" @@ -1,6 +1,3 @@ -from sortedcontainers import SortedDict - - class MyCalendar: def __init__(self): self.sd = SortedDict() diff --git "a/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/README.md" "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/README.md" index a53ff9a0a21f1..7ed8b092d36e0 100644 --- "a/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/README.md" +++ "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/README.md" @@ -403,9 +403,6 @@ class Solution { #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def numsGame(self, nums: List[int]) -> List[int]: l = SortedList() diff --git "a/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution2.py" "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution2.py" index aad34c9845934..16088eddc4e2d 100644 --- "a/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution2.py" +++ "b/lcp/LCP 24. \346\225\260\345\255\227\346\270\270\346\210\217/Solution2.py" @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def numsGame(self, nums: List[int]) -> List[int]: l = SortedList() diff --git "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md" "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md" index b9fe5e883c2c5..fd875e6061c85 100644 --- "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md" +++ "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/README.md" @@ -89,9 +89,6 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcp/LCP%2052.%20%E4%BA%8C% # self.left = None # self.right = None -from sortedcontainers import SortedList - - class Solution: def getNumber(self, root: Optional[TreeNode], ops: List[List[int]]) -> int: def dfs(root): diff --git "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py" "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py" index 2e140bdb7fd66..fe7d41876e7c8 100644 --- "a/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py" +++ "b/lcp/LCP 52. \344\272\214\345\217\211\346\220\234\347\264\242\346\240\221\346\237\223\350\211\262/Solution.py" @@ -5,8 +5,6 @@ # self.left = None # self.right = None -from sortedcontainers import SortedList - class Solution: def getNumber(self, root: Optional[TreeNode], ops: List[List[int]]) -> int: diff --git a/solution/0200-0299/0220.Contains Duplicate III/README.md b/solution/0200-0299/0220.Contains Duplicate III/README.md index 2f84e722b2274..06216f73ad7f1 100644 --- a/solution/0200-0299/0220.Contains Duplicate III/README.md +++ b/solution/0200-0299/0220.Contains Duplicate III/README.md @@ -84,9 +84,6 @@ abs(nums[i] - nums[j]) <= valueDiff --> abs(1 - 1) <= 0 #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def containsNearbyAlmostDuplicate( self, nums: List[int], indexDiff: int, valueDiff: int diff --git a/solution/0200-0299/0220.Contains Duplicate III/README_EN.md b/solution/0200-0299/0220.Contains Duplicate III/README_EN.md index 847747f02a0b6..817fd6b472784 100644 --- a/solution/0200-0299/0220.Contains Duplicate III/README_EN.md +++ b/solution/0200-0299/0220.Contains Duplicate III/README_EN.md @@ -82,9 +82,6 @@ The time complexity is $O(n \times \log k)$, where $n$ is the length of the arra #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def containsNearbyAlmostDuplicate( self, nums: List[int], indexDiff: int, valueDiff: int diff --git a/solution/0200-0299/0220.Contains Duplicate III/Solution.py b/solution/0200-0299/0220.Contains Duplicate III/Solution.py index d766efd4d491a..0395f4cd73f7c 100644 --- a/solution/0200-0299/0220.Contains Duplicate III/Solution.py +++ b/solution/0200-0299/0220.Contains Duplicate III/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class Solution: def containsNearbyAlmostDuplicate( self, nums: List[int], indexDiff: int, valueDiff: int diff --git a/solution/0200-0299/0225.Implement Stack using Queues/README.md b/solution/0200-0299/0225.Implement Stack using Queues/README.md index 025dd7f130705..1bb33b2e1b7bc 100644 --- a/solution/0200-0299/0225.Implement Stack using Queues/README.md +++ b/solution/0200-0299/0225.Implement Stack using Queues/README.md @@ -126,8 +126,6 @@ class MyStack: #### Java ```java -import java.util.Deque; - class MyStack { private Deque q1 = new ArrayDeque<>(); private Deque q2 = new ArrayDeque<>(); diff --git a/solution/0200-0299/0225.Implement Stack using Queues/README_EN.md b/solution/0200-0299/0225.Implement Stack using Queues/README_EN.md index bbe6a4bd2753b..a154dc2164c98 100644 --- a/solution/0200-0299/0225.Implement Stack using Queues/README_EN.md +++ b/solution/0200-0299/0225.Implement Stack using Queues/README_EN.md @@ -121,8 +121,6 @@ class MyStack: #### Java ```java -import java.util.Deque; - class MyStack { private Deque q1 = new ArrayDeque<>(); private Deque q2 = new ArrayDeque<>(); diff --git a/solution/0200-0299/0225.Implement Stack using Queues/Solution.java b/solution/0200-0299/0225.Implement Stack using Queues/Solution.java index ee5e1fe139fda..3e839b22864c9 100644 --- a/solution/0200-0299/0225.Implement Stack using Queues/Solution.java +++ b/solution/0200-0299/0225.Implement Stack using Queues/Solution.java @@ -1,5 +1,3 @@ -import java.util.Deque; - class MyStack { private Deque q1 = new ArrayDeque<>(); private Deque q2 = new ArrayDeque<>(); @@ -37,4 +35,4 @@ public boolean empty() { * int param_2 = obj.pop(); * int param_3 = obj.top(); * boolean param_4 = obj.empty(); - */ \ No newline at end of file + */ diff --git a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README.md b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README.md index 5e2f868f6579d..40b43bb254912 100644 --- a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README.md +++ b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README.md @@ -83,9 +83,6 @@ summaryRanges.getIntervals(); // 返回 [[1, 3], [6, 7]] #### Python3 ```python -from sortedcontainers import SortedDict - - class SummaryRanges: def __init__(self): self.mp = SortedDict() diff --git a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README_EN.md b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README_EN.md index 4564125c8466d..544db902d32c2 100644 --- a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README_EN.md +++ b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/README_EN.md @@ -77,9 +77,6 @@ summaryRanges.getIntervals(); // return [[1, 3], [6, 7]] #### Python3 ```python -from sortedcontainers import SortedDict - - class SummaryRanges: def __init__(self): self.mp = SortedDict() diff --git a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/Solution.py b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/Solution.py index 38fc926882c45..f09e535c8e7da 100644 --- a/solution/0300-0399/0352.Data Stream as Disjoint Intervals/Solution.py +++ b/solution/0300-0399/0352.Data Stream as Disjoint Intervals/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedDict - - class SummaryRanges: def __init__(self): self.mp = SortedDict() diff --git a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README.md b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README.md index dda2cb4308245..fd10fdf0d4b8a 100644 --- a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README.md +++ b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README.md @@ -76,9 +76,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def maxSumSubmatrix(self, matrix: List[List[int]], k: int) -> int: m, n = len(matrix), len(matrix[0]) diff --git a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README_EN.md b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README_EN.md index 42c55f6852f72..20329fcc2f3a0 100644 --- a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README_EN.md +++ b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/README_EN.md @@ -73,9 +73,6 @@ The time complexity is $O(m^2 \times n \times \log n)$, and the space complexity #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def maxSumSubmatrix(self, matrix: List[List[int]], k: int) -> int: m, n = len(matrix), len(matrix[0]) diff --git a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/Solution.py b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/Solution.py index 9e8e82b985567..69d17cefd3888 100644 --- a/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/Solution.py +++ b/solution/0300-0399/0363.Max Sum of Rectangle No Larger Than K/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class Solution: def maxSumSubmatrix(self, matrix: List[List[int]], k: int) -> int: m, n = len(matrix), len(matrix[0]) diff --git a/solution/0400-0499/0480.Sliding Window Median/README.md b/solution/0400-0499/0480.Sliding Window Median/README.md index d13650be743e3..69166ef2545ff 100644 --- a/solution/0400-0499/0480.Sliding Window Median/README.md +++ b/solution/0400-0499/0480.Sliding Window Median/README.md @@ -466,9 +466,6 @@ func (h *hp) Pop() any { #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]: l = SortedList() diff --git a/solution/0400-0499/0480.Sliding Window Median/README_EN.md b/solution/0400-0499/0480.Sliding Window Median/README_EN.md index dc86f4186deeb..e1e9384fd8a51 100644 --- a/solution/0400-0499/0480.Sliding Window Median/README_EN.md +++ b/solution/0400-0499/0480.Sliding Window Median/README_EN.md @@ -36,7 +36,7 @@ tags:
 Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
 Output: [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000]
-Explanation: 
+Explanation:
 Window position                Median
 ---------------                -----
 [1  3  -1] -3  5  3  6  7        1
@@ -470,9 +470,6 @@ The time complexity is $O(n \log k)$, and the space complexity is $O(k)$. Here,
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
         l = SortedList()
diff --git a/solution/0400-0499/0480.Sliding Window Median/Solution2.py b/solution/0400-0499/0480.Sliding Window Median/Solution2.py
index 389ee94665db9..78c2c0e44e783 100644
--- a/solution/0400-0499/0480.Sliding Window Median/Solution2.py	
+++ b/solution/0400-0499/0480.Sliding Window Median/Solution2.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
         l = SortedList()
diff --git a/solution/0700-0799/0716.Max Stack/README.md b/solution/0700-0799/0716.Max Stack/README.md
index ac66bac91f6f8..311e7bd0726d9 100644
--- a/solution/0700-0799/0716.Max Stack/README.md	
+++ b/solution/0700-0799/0716.Max Stack/README.md	
@@ -98,9 +98,6 @@ stk.top();     // 返回 5,[5] - 栈没有改变
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Node:
     def __init__(self, val=0):
         self.val = val
diff --git a/solution/0700-0799/0716.Max Stack/README_EN.md b/solution/0700-0799/0716.Max Stack/README_EN.md
index 126d4b2525861..56cd8b33383a6 100644
--- a/solution/0700-0799/0716.Max Stack/README_EN.md	
+++ b/solution/0700-0799/0716.Max Stack/README_EN.md	
@@ -80,9 +80,6 @@ stk.top();     // return 5, [5] the stack did not change
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Node:
     def __init__(self, val=0):
         self.val = val
diff --git a/solution/0700-0799/0716.Max Stack/Solution.py b/solution/0700-0799/0716.Max Stack/Solution.py
index ba53bd19fd7aa..135f105993f16 100644
--- a/solution/0700-0799/0716.Max Stack/Solution.py	
+++ b/solution/0700-0799/0716.Max Stack/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Node:
     def __init__(self, val=0):
         self.val = val
diff --git a/solution/0700-0799/0729.My Calendar I/README.md b/solution/0700-0799/0729.My Calendar I/README.md
index 0d1bf730d0f95..047d70683daae 100644
--- a/solution/0700-0799/0729.My Calendar I/README.md	
+++ b/solution/0700-0799/0729.My Calendar I/README.md	
@@ -78,9 +78,6 @@ myCalendar.book(20, 30); // return True ,这个日程安排可以添加到日
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class MyCalendar:
 
     def __init__(self):
diff --git a/solution/0700-0799/0729.My Calendar I/README_EN.md b/solution/0700-0799/0729.My Calendar I/README_EN.md
index a164293f28af7..fa87a83e9b99f 100644
--- a/solution/0700-0799/0729.My Calendar I/README_EN.md	
+++ b/solution/0700-0799/0729.My Calendar I/README_EN.md	
@@ -70,9 +70,6 @@ myCalendar.book(20, 30); // return True, The event can be booked, as the first e
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class MyCalendar:
 
     def __init__(self):
diff --git a/solution/0700-0799/0729.My Calendar I/Solution.py b/solution/0700-0799/0729.My Calendar I/Solution.py
index d1f07110b5437..bfcc0082c7fa7 100644
--- a/solution/0700-0799/0729.My Calendar I/Solution.py	
+++ b/solution/0700-0799/0729.My Calendar I/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
 class MyCalendar:
     def __init__(self):
         self.sd = SortedDict()
diff --git a/solution/0700-0799/0731.My Calendar II/README.md b/solution/0700-0799/0731.My Calendar II/README.md
index a6a10f70138c4..ad76989e5f8d6 100644
--- a/solution/0700-0799/0731.My Calendar II/README.md	
+++ b/solution/0700-0799/0731.My Calendar II/README.md	
@@ -81,9 +81,6 @@ myCalendarTwo.book(25, 55); // 返回 True,能够预定该日程,因为时
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class MyCalendarTwo:
 
     def __init__(self):
diff --git a/solution/0700-0799/0731.My Calendar II/README_EN.md b/solution/0700-0799/0731.My Calendar II/README_EN.md
index 87a27bf616e87..0d5beb8e8da83 100644
--- a/solution/0700-0799/0731.My Calendar II/README_EN.md	
+++ b/solution/0700-0799/0731.My Calendar II/README_EN.md	
@@ -46,9 +46,9 @@ tags:
 
 Explanation
 MyCalendarTwo myCalendarTwo = new MyCalendarTwo();
-myCalendarTwo.book(10, 20); // return True, The event can be booked. 
-myCalendarTwo.book(50, 60); // return True, The event can be booked. 
-myCalendarTwo.book(10, 40); // return True, The event can be double booked. 
+myCalendarTwo.book(10, 20); // return True, The event can be booked.
+myCalendarTwo.book(50, 60); // return True, The event can be booked.
+myCalendarTwo.book(10, 40); // return True, The event can be double booked.
 myCalendarTwo.book(5, 15);  // return False, The event cannot be booked, because it would result in a triple booking.
 myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked.
 myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
@@ -79,9 +79,6 @@ The time complexity is $O(n^2)$, and the space complexity is $O(n)$, where $n$ i
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class MyCalendarTwo:
 
     def __init__(self):
diff --git a/solution/0700-0799/0731.My Calendar II/Solution.py b/solution/0700-0799/0731.My Calendar II/Solution.py
index 5d7b8be7283db..3b10f8b7eded9 100644
--- a/solution/0700-0799/0731.My Calendar II/Solution.py	
+++ b/solution/0700-0799/0731.My Calendar II/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
 class MyCalendarTwo:
     def __init__(self):
         self.sd = SortedDict()
diff --git a/solution/0800-0899/0846.Hand of Straights/README.md b/solution/0800-0899/0846.Hand of Straights/README.md
index 86dacf4f968e7..42532a8a87d77 100644
--- a/solution/0800-0899/0846.Hand of Straights/README.md	
+++ b/solution/0800-0899/0846.Hand of Straights/README.md	
@@ -213,9 +213,6 @@ function isNStraightHand(hand: number[], groupSize: number) {
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
         if len(hand) % groupSize != 0:
diff --git a/solution/0800-0899/0846.Hand of Straights/README_EN.md b/solution/0800-0899/0846.Hand of Straights/README_EN.md
index 97943c10c5a70..e8eef656750af 100644
--- a/solution/0800-0899/0846.Hand of Straights/README_EN.md	
+++ b/solution/0800-0899/0846.Hand of Straights/README_EN.md	
@@ -198,9 +198,6 @@ function isNStraightHand(hand: number[], groupSize: number) {
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
         if len(hand) % groupSize != 0:
diff --git a/solution/0800-0899/0846.Hand of Straights/Solution2.py b/solution/0800-0899/0846.Hand of Straights/Solution2.py
index 09f7e6d10e146..60cc15f201b41 100644
--- a/solution/0800-0899/0846.Hand of Straights/Solution2.py	
+++ b/solution/0800-0899/0846.Hand of Straights/Solution2.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
         if len(hand) % groupSize != 0:
diff --git a/solution/0800-0899/0855.Exam Room/README.md b/solution/0800-0899/0855.Exam Room/README.md
index 903b2c2e0e432..8102687587ccf 100644
--- a/solution/0800-0899/0855.Exam Room/README.md	
+++ b/solution/0800-0899/0855.Exam Room/README.md	
@@ -81,9 +81,6 @@ examRoom.seat(); // 返回 5,学生最后坐在 5 号座位。
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class ExamRoom:
     def __init__(self, n: int):
         def dist(x):
diff --git a/solution/0800-0899/0855.Exam Room/README_EN.md b/solution/0800-0899/0855.Exam Room/README_EN.md
index 63335bebf97c1..9b4ff29c1b116 100644
--- a/solution/0800-0899/0855.Exam Room/README_EN.md	
+++ b/solution/0800-0899/0855.Exam Room/README_EN.md	
@@ -81,9 +81,6 @@ The time complexity is $O(\log n)$, and the space complexity is $O(n)$. Here, $n
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class ExamRoom:
     def __init__(self, n: int):
         def dist(x):
diff --git a/solution/0800-0899/0855.Exam Room/Solution.py b/solution/0800-0899/0855.Exam Room/Solution.py
index 38503c88b2686..ee8b304198a31 100644
--- a/solution/0800-0899/0855.Exam Room/Solution.py	
+++ b/solution/0800-0899/0855.Exam Room/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class ExamRoom:
     def __init__(self, n: int):
         def dist(x):
diff --git a/solution/0900-0999/0975.Odd Even Jump/README.md b/solution/0900-0999/0975.Odd Even Jump/README.md
index f5e96324a9b87..f0bbd0397fc28 100644
--- a/solution/0900-0999/0975.Odd Even Jump/README.md	
+++ b/solution/0900-0999/0975.Odd Even Jump/README.md	
@@ -110,9 +110,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def oddEvenJumps(self, arr: List[int]) -> int:
         @cache
diff --git a/solution/0900-0999/0975.Odd Even Jump/README_EN.md b/solution/0900-0999/0975.Odd Even Jump/README_EN.md
index 83ef2b86369a4..f3d8f0f75c976 100644
--- a/solution/0900-0999/0975.Odd Even Jump/README_EN.md	
+++ b/solution/0900-0999/0975.Odd Even Jump/README_EN.md	
@@ -40,7 +40,7 @@ tags:
 
 Input: arr = [10,13,12,14,15]
 Output: 2
-Explanation: 
+Explanation:
 From starting index i = 0, we can make our 1st jump to i = 2 (since arr[2] is the smallest among arr[1], arr[2], arr[3], arr[4] that is greater or equal to arr[0]), then we cannot jump any more.
 From starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more.
 From starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end.
@@ -54,7 +54,7 @@ jumps.
 
 Input: arr = [2,3,1,1,4]
 Output: 3
-Explanation: 
+Explanation:
 From starting index i = 0, we make jumps to i = 1, i = 2, i = 3:
 During our 1st jump (odd-numbered), we first jump to i = 1 because arr[1] is the smallest value in [arr[1], arr[2], arr[3], arr[4]] that is greater than or equal to arr[0].
 During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because arr[2] is the largest value in [arr[2], arr[3], arr[4]] that is less than or equal to arr[1]. arr[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3
@@ -98,9 +98,6 @@ number of jumps.
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def oddEvenJumps(self, arr: List[int]) -> int:
         @cache
diff --git a/solution/0900-0999/0975.Odd Even Jump/Solution.py b/solution/0900-0999/0975.Odd Even Jump/Solution.py
index b4eed3dae1bff..64294321e35bf 100644
--- a/solution/0900-0999/0975.Odd Even Jump/Solution.py	
+++ b/solution/0900-0999/0975.Odd Even Jump/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def oddEvenJumps(self, arr: List[int]) -> int:
         @cache
diff --git a/solution/1000-1099/1030.Matrix Cells in Distance Order/README.md b/solution/1000-1099/1030.Matrix Cells in Distance Order/README.md
index 4fff950b9bf43..399dc4c07a588 100644
--- a/solution/1000-1099/1030.Matrix Cells in Distance Order/README.md	
+++ b/solution/1000-1099/1030.Matrix Cells in Distance Order/README.md	
@@ -108,8 +108,6 @@ class Solution:
 #### Java
 
 ```java
-import java.util.Deque;
-
 class Solution {
     public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {
         Deque q = new ArrayDeque<>();
diff --git a/solution/1000-1099/1030.Matrix Cells in Distance Order/README_EN.md b/solution/1000-1099/1030.Matrix Cells in Distance Order/README_EN.md
index 2bc0ee8e48d31..a81f744247be6 100644
--- a/solution/1000-1099/1030.Matrix Cells in Distance Order/README_EN.md	
+++ b/solution/1000-1099/1030.Matrix Cells in Distance Order/README_EN.md	
@@ -100,8 +100,6 @@ class Solution:
 #### Java
 
 ```java
-import java.util.Deque;
-
 class Solution {
     public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {
         Deque q = new ArrayDeque<>();
diff --git a/solution/1000-1099/1030.Matrix Cells in Distance Order/Solution.java b/solution/1000-1099/1030.Matrix Cells in Distance Order/Solution.java
index 012b93f09ea2b..b764e47022f05 100644
--- a/solution/1000-1099/1030.Matrix Cells in Distance Order/Solution.java	
+++ b/solution/1000-1099/1030.Matrix Cells in Distance Order/Solution.java	
@@ -1,5 +1,3 @@
-import java.util.Deque;
-
 class Solution {
     public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {
         Deque q = new ArrayDeque<>();
@@ -24,4 +22,4 @@ public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {
         }
         return ans;
     }
-}
\ No newline at end of file
+}
diff --git a/solution/1100-1199/1172.Dinner Plate Stacks/README.md b/solution/1100-1199/1172.Dinner Plate Stacks/README.md
index fe6494be79d35..ced8ea8849c43 100644
--- a/solution/1100-1199/1172.Dinner Plate Stacks/README.md	
+++ b/solution/1100-1199/1172.Dinner Plate Stacks/README.md	
@@ -65,14 +65,14 @@ D.popAtStack(0);   // 返回 20。栈的现状为:       4 21
                                             ﹈ ﹈ ﹈
 D.popAtStack(2);   // 返回 21。栈的现状为:       4
                                             1  3  5
-                                            ﹈ ﹈ ﹈ 
+                                            ﹈ ﹈ ﹈
 D.pop()            // 返回 5。栈的现状为:        4
-                                            1  3 
-                                            ﹈ ﹈  
-D.pop()            // 返回 4。栈的现状为:    1  3 
-                                           ﹈ ﹈   
-D.pop()            // 返回 3。栈的现状为:    1 
-                                           ﹈   
+                                            1  3
+                                            ﹈ ﹈
+D.pop()            // 返回 4。栈的现状为:    1  3
+                                           ﹈ ﹈
+D.pop()            // 返回 3。栈的现状为:    1
+                                           ﹈
 D.pop()            // 返回 1。现在没有栈。
 D.pop()            // 返回 -1。仍然没有栈。
 
@@ -124,9 +124,6 @@ D.pop() // 返回 -1。仍然没有栈。 #### Python3 ```python -from sortedcontainers import SortedSet - - class DinnerPlates: def __init__(self, capacity: int): self.capacity = capacity diff --git a/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md b/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md index d57e8331e0fc9..a1b5f39c39692 100644 --- a/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md +++ b/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md @@ -42,7 +42,7 @@ tags: Output [null, null, null, null, null, null, 2, null, null, 20, 21, 5, 4, 3, 1, -1] -Explanation: +Explanation: DinnerPlates D = DinnerPlates(2); // Initialize with capacity = 2 D.push(1); D.push(2); @@ -65,14 +65,14 @@ D.popAtStack(0); // Returns 20. The stacks are now: 4 21 ﹈ ﹈ ﹈ D.popAtStack(2); // Returns 21. The stacks are now: 4 1 3 5 - ﹈ ﹈ ﹈ + ﹈ ﹈ ﹈ D.pop() // Returns 5. The stacks are now: 4 - 1 3 - ﹈ ﹈ -D.pop() // Returns 4. The stacks are now: 1 3 - ﹈ ﹈ -D.pop() // Returns 3. The stacks are now: 1 - ﹈ + 1 3 + ﹈ ﹈ +D.pop() // Returns 4. The stacks are now: 1 3 + ﹈ ﹈ +D.pop() // Returns 3. The stacks are now: 1 + ﹈ D.pop() // Returns 1. There are no stacks. D.pop() // Returns -1. There are still no stacks.
@@ -123,9 +123,6 @@ The time complexity is $(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedSet - - class DinnerPlates: def __init__(self, capacity: int): self.capacity = capacity diff --git a/solution/1100-1199/1172.Dinner Plate Stacks/Solution.py b/solution/1100-1199/1172.Dinner Plate Stacks/Solution.py index 346bd37088ef6..1e9c7f7c190e3 100644 --- a/solution/1100-1199/1172.Dinner Plate Stacks/Solution.py +++ b/solution/1100-1199/1172.Dinner Plate Stacks/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class DinnerPlates: def __init__(self, capacity: int): self.capacity = capacity diff --git a/solution/1200-1299/1244.Design A Leaderboard/README.md b/solution/1200-1299/1244.Design A Leaderboard/README.md index 887104c8c33bc..07fda43ac4cb1 100644 --- a/solution/1200-1299/1244.Design A Leaderboard/README.md +++ b/solution/1200-1299/1244.Design A Leaderboard/README.md @@ -98,9 +98,6 @@ leaderboard.top(3); // returns 141 = 51 + 51 + 39; #### Python3 ```python -from sortedcontainers import SortedList - - class Leaderboard: def __init__(self): self.d = defaultdict(int) diff --git a/solution/1200-1299/1244.Design A Leaderboard/README_EN.md b/solution/1200-1299/1244.Design A Leaderboard/README_EN.md index 9f7243af74731..af6051c9ab2bb 100644 --- a/solution/1200-1299/1244.Design A Leaderboard/README_EN.md +++ b/solution/1200-1299/1244.Design A Leaderboard/README_EN.md @@ -87,9 +87,6 @@ The space complexity is $O(n)$, where $n$ is the number of players. #### Python3 ```python -from sortedcontainers import SortedList - - class Leaderboard: def __init__(self): self.d = defaultdict(int) diff --git a/solution/1200-1299/1244.Design A Leaderboard/Solution.py b/solution/1200-1299/1244.Design A Leaderboard/Solution.py index 32ea95f9e27c1..8b1c3baed93eb 100644 --- a/solution/1200-1299/1244.Design A Leaderboard/Solution.py +++ b/solution/1200-1299/1244.Design A Leaderboard/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Leaderboard: def __init__(self): self.d = defaultdict(int) diff --git a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README.md b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README.md index 08abf22129995..7b0a32e6cbd23 100644 --- a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README.md +++ b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README.md @@ -194,9 +194,6 @@ func isPossibleDivide(nums []int, k int) bool { #### Python3 ```python -from sortedcontainers import SortedDict - - class Solution: def isPossibleDivide(self, nums: List[int], k: int) -> bool: if len(nums) % k != 0: diff --git a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README_EN.md b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README_EN.md index 4152385b34e17..3357bd9a99781 100644 --- a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README_EN.md +++ b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/README_EN.md @@ -192,9 +192,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedDict - - class Solution: def isPossibleDivide(self, nums: List[int], k: int) -> bool: if len(nums) % k != 0: diff --git a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/Solution2.py b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/Solution2.py index f925479ad6afc..b0f6493ebbd89 100644 --- a/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/Solution2.py +++ b/solution/1200-1299/1296.Divide Array in Sets of K Consecutive Numbers/Solution2.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedDict - - class Solution: def isPossibleDivide(self, nums: List[int], k: int) -> bool: if len(nums) % k != 0: diff --git a/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md b/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md index 1cac6d0a0dd19..83dbe80cffbf8 100644 --- a/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md +++ b/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md @@ -68,7 +68,7 @@ tweetCounts.recordTweet("tweet3", 0); tweetCounts.recordTweet("tweet3", 60); tweetCounts.recordTweet("tweet3", 10); // "tweet3" 发布推文的时间分别是 0, 10 和 60 。 tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // 返回 [2]。统计频率是每分钟(60 秒),因此只有一个有效时间间隔 [0,60> - > 2 条推文。 -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // 返回 [2,1]。统计频率是每分钟(60 秒),因此有两个有效时间间隔 1) [0,60> - > 2 条推文,和 2) [60,61> - > 1 条推文。 +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // 返回 [2,1]。统计频率是每分钟(60 秒),因此有两个有效时间间隔 1) [0,60> - > 2 条推文,和 2) [60,61> - > 1 条推文。 tweetCounts.recordTweet("tweet3", 120); // "tweet3" 发布推文的时间分别是 0, 10, 60 和 120 。 tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // 返回 [4]。统计频率是每小时(3600 秒),因此只有一个有效时间间隔 [0,211> - > 4 条推文。
@@ -104,9 +104,6 @@ tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // 返 #### Python3 ```python -from sortedcontainers import SortedList - - class TweetCounts: def __init__(self): self.d = {"minute": 60, "hour": 3600, "day": 86400} diff --git a/solution/1300-1399/1348.Tweet Counts Per Frequency/README_EN.md b/solution/1300-1399/1348.Tweet Counts Per Frequency/README_EN.md index 8117b556fb3ab..232f1626ca0da 100644 --- a/solution/1300-1399/1348.Tweet Counts Per Frequency/README_EN.md +++ b/solution/1300-1399/1348.Tweet Counts Per Frequency/README_EN.md @@ -92,9 +92,6 @@ tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, #### Python3 ```python -from sortedcontainers import SortedList - - class TweetCounts: def __init__(self): self.d = {"minute": 60, "hour": 3600, "day": 86400} diff --git a/solution/1300-1399/1348.Tweet Counts Per Frequency/Solution.py b/solution/1300-1399/1348.Tweet Counts Per Frequency/Solution.py index 5f1a28e7874f0..cc0547795888b 100644 --- a/solution/1300-1399/1348.Tweet Counts Per Frequency/Solution.py +++ b/solution/1300-1399/1348.Tweet Counts Per Frequency/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class TweetCounts: def __init__(self): self.d = {"minute": 60, "hour": 3600, "day": 86400} diff --git a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README.md b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README.md index 313692f014fd4..ff3f2f4c6b6e9 100644 --- a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README.md +++ b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README.md @@ -32,10 +32,10 @@ tags:

示例 1:

输入:nums = [8,2,4,7], limit = 4
-输出:2 
+输出:2
 解释:所有子数组如下:
 [8] 最大绝对差 |8-8| = 0 <= 4.
-[8,2] 最大绝对差 |8-2| = 6 > 4. 
+[8,2] 最大绝对差 |8-2| = 6 > 4.
 [8,2,4] 最大绝对差 |8-2| = 6 > 4.
 [8,2,4,7] 最大绝对差 |8-2| = 6 > 4.
 [2] 最大绝对差 |2-2| = 0 <= 4.
@@ -43,14 +43,14 @@ tags:
 [2,4,7] 最大绝对差 |2-7| = 5 > 4.
 [4] 最大绝对差 |4-4| = 0 <= 4.
 [4,7] 最大绝对差 |4-7| = 3 <= 4.
-[7] 最大绝对差 |7-7| = 0 <= 4. 
+[7] 最大绝对差 |7-7| = 0 <= 4.
 因此,满足题意的最长子数组的长度为 2 。
 

示例 2:

输入:nums = [10,1,2,4,7,2], limit = 5
-输出:4 
+输出:4
 解释:满足题意的最长子数组是 [2,4,7,2],其最大绝对差 |2-7| = 5 <= 5 。
 
@@ -87,9 +87,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def longestSubarray(self, nums: List[int], limit: int) -> int: sl = SortedList() diff --git a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md index aa8009bc36447..07f167125aab5 100644 --- a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md +++ b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md @@ -30,10 +30,10 @@ tags:
 Input: nums = [8,2,4,7], limit = 4
-Output: 2 
-Explanation: All subarrays are: 
+Output: 2
+Explanation: All subarrays are:
 [8] with maximum absolute diff |8-8| = 0 <= 4.
-[8,2] with maximum absolute diff |8-2| = 6 > 4. 
+[8,2] with maximum absolute diff |8-2| = 6 > 4.
 [8,2,4] with maximum absolute diff |8-2| = 6 > 4.
 [8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.
 [2] with maximum absolute diff |2-2| = 0 <= 4.
@@ -41,7 +41,7 @@ tags:
 [2,4,7] with maximum absolute diff |2-7| = 5 > 4.
 [4] with maximum absolute diff |4-4| = 0 <= 4.
 [4,7] with maximum absolute diff |4-7| = 3 <= 4.
-[7] with maximum absolute diff |7-7| = 0 <= 4. 
+[7] with maximum absolute diff |7-7| = 0 <= 4.
 Therefore, the size of the longest subarray is 2.
 
@@ -49,7 +49,7 @@ Therefore, the size of the longest subarray is 2.
 Input: nums = [10,1,2,4,7,2], limit = 5
-Output: 4 
+Output: 4
 Explanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.
 
@@ -86,9 +86,6 @@ The time complexity is $O(n \log n)$, and the space complexity is $O(n)$. Here, #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def longestSubarray(self, nums: List[int], limit: int) -> int: sl = SortedList() diff --git a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/Solution.py b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/Solution.py index 88444c45aa4c2..6f4958617d914 100644 --- a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/Solution.py +++ b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def longestSubarray(self, nums: List[int], limit: int) -> int: sl = SortedList() diff --git a/solution/1400-1499/1488.Avoid Flood in The City/README.md b/solution/1400-1499/1488.Avoid Flood in The City/README.md index 219182f7c88f2..b1c04f5fd8b1e 100644 --- a/solution/1400-1499/1488.Avoid Flood in The City/README.md +++ b/solution/1400-1499/1488.Avoid Flood in The City/README.md @@ -110,9 +110,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def avoidFlood(self, rains: List[int]) -> List[int]: n = len(rains) diff --git a/solution/1400-1499/1488.Avoid Flood in The City/README_EN.md b/solution/1400-1499/1488.Avoid Flood in The City/README_EN.md index e62ec47805b8e..0ba064d885617 100644 --- a/solution/1400-1499/1488.Avoid Flood in The City/README_EN.md +++ b/solution/1400-1499/1488.Avoid Flood in The City/README_EN.md @@ -108,9 +108,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def avoidFlood(self, rains: List[int]) -> List[int]: n = len(rains) diff --git a/solution/1400-1499/1488.Avoid Flood in The City/Solution.py b/solution/1400-1499/1488.Avoid Flood in The City/Solution.py index bc77246f2cf8d..913c376f5caed 100644 --- a/solution/1400-1499/1488.Avoid Flood in The City/Solution.py +++ b/solution/1400-1499/1488.Avoid Flood in The City/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def avoidFlood(self, rains: List[int]) -> List[int]: n = len(rains) diff --git a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md index 42fce2a0f0743..8c534cf5a9efe 100644 --- a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md +++ b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md @@ -41,8 +41,8 @@ tags:

-输入:k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
-输出:[1] 
+输入:k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3]
+输出:[1]
 解释:
 所有服务器一开始都是空闲的。
 前 3 个请求分别由前 3 台服务器依次处理。
@@ -119,9 +119,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def busiestServers(self, k: int, arrival: List[int], load: List[int]) -> List[int]:
         free = SortedList(range(k))
diff --git a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md
index e19edfd9efc2e..6c8ae0631143e 100644
--- a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md	
+++ b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md	
@@ -38,9 +38,9 @@ tags:
 

Example 1:

-Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] 
-Output: [1] 
-Explanation: 
+Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3]
+Output: [1]
+Explanation:
 All of the servers start out available.
 The first 3 requests are handled by the first 3 servers in order.
 Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.
@@ -53,7 +53,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. H
 
 Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]
 Output: [0]
-Explanation: 
+Explanation:
 The first 3 requests are handled by first 3 servers.
 Request 3 comes in. It is handled by server 0 since the server is available.
 Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.
@@ -91,9 +91,6 @@ Server 0 handled two requests, while servers 1 and 2 handled one request each. H
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def busiestServers(self, k: int, arrival: List[int], load: List[int]) -> List[int]:
         free = SortedList(range(k))
diff --git a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/Solution.py b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/Solution.py
index 577a05324a8a9..9d96261b57513 100644
--- a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/Solution.py	
+++ b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def busiestServers(self, k: int, arrival: List[int], load: List[int]) -> List[int]:
         free = SortedList(range(k))
diff --git a/solution/1800-1899/1825.Finding MK Average/README.md b/solution/1800-1899/1825.Finding MK Average/README.md
index 30c037ce7ab91..f7b67495227d5 100644
--- a/solution/1800-1899/1825.Finding MK Average/README.md	
+++ b/solution/1800-1899/1825.Finding MK Average/README.md	
@@ -52,7 +52,7 @@ tags:
 [null, null, null, -1, null, 3, null, null, null, 5]
 
 解释:
-MKAverage obj = new MKAverage(3, 1); 
+MKAverage obj = new MKAverage(3, 1);
 obj.addElement(3);        // 当前元素为 [3]
 obj.addElement(1);        // 当前元素为 [3,1]
 obj.calculateMKAverage(); // 返回 -1 ,因为 m = 3 ,但数据流中只有 2 个元素
@@ -112,9 +112,6 @@ obj.calculateMKAverage(); // 最后 3 个元素为 [5,5,5]
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
@@ -454,9 +451,6 @@ func (this *MKAverage) CalculateMKAverage() int {
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
diff --git a/solution/1800-1899/1825.Finding MK Average/README_EN.md b/solution/1800-1899/1825.Finding MK Average/README_EN.md
index e00b194b4ee85..12b3147398684 100644
--- a/solution/1800-1899/1825.Finding MK Average/README_EN.md	
+++ b/solution/1800-1899/1825.Finding MK Average/README_EN.md	
@@ -51,7 +51,7 @@ tags:
 [null, null, null, -1, null, 3, null, null, null, 5]
 
 Explanation
-MKAverage obj = new MKAverage(3, 1); 
+MKAverage obj = new MKAverage(3, 1);
 obj.addElement(3);        // current elements are [3]
 obj.addElement(1);        // current elements are [3,1]
 obj.calculateMKAverage(); // return -1, because m = 3 and only 2 elements exist.
@@ -110,9 +110,6 @@ In terms of time complexity, each call to the $addElement(num)$ function has a t
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
@@ -452,9 +449,6 @@ func (this *MKAverage) CalculateMKAverage() int {
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
diff --git a/solution/1800-1899/1825.Finding MK Average/Solution.py b/solution/1800-1899/1825.Finding MK Average/Solution.py
index 12aae3a4d20f9..b99a53af6631e 100644
--- a/solution/1800-1899/1825.Finding MK Average/Solution.py	
+++ b/solution/1800-1899/1825.Finding MK Average/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
diff --git a/solution/1800-1899/1825.Finding MK Average/Solution2.py b/solution/1800-1899/1825.Finding MK Average/Solution2.py
index da39efcc0edff..de8b84dc9b0da 100644
--- a/solution/1800-1899/1825.Finding MK Average/Solution2.py	
+++ b/solution/1800-1899/1825.Finding MK Average/Solution2.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class MKAverage:
     def __init__(self, m: int, k: int):
         self.m = m
diff --git a/solution/1800-1899/1847.Closest Room/README.md b/solution/1800-1899/1847.Closest Room/README.md
index ff0413959f454..2dea05561446b 100644
--- a/solution/1800-1899/1847.Closest Room/README.md	
+++ b/solution/1800-1899/1847.Closest Room/README.md	
@@ -90,9 +90,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def closestRoom(
         self, rooms: List[List[int]], queries: List[List[int]]
diff --git a/solution/1800-1899/1847.Closest Room/README_EN.md b/solution/1800-1899/1847.Closest Room/README_EN.md
index a9afd9e1095c9..e7a6c38f16c9f 100644
--- a/solution/1800-1899/1847.Closest Room/README_EN.md	
+++ b/solution/1800-1899/1847.Closest Room/README_EN.md	
@@ -88,9 +88,6 @@ The time complexity is $O(n \times \log n + k \times \log k)$, and the space com
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def closestRoom(
         self, rooms: List[List[int]], queries: List[List[int]]
diff --git a/solution/1800-1899/1847.Closest Room/Solution.py b/solution/1800-1899/1847.Closest Room/Solution.py
index b7d0408462410..a2fe6b3105384 100644
--- a/solution/1800-1899/1847.Closest Room/Solution.py	
+++ b/solution/1800-1899/1847.Closest Room/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def closestRoom(
         self, rooms: List[List[int]], queries: List[List[int]]
diff --git a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README.md b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README.md
index 77eb92ff2e9cb..fe261f9db8586 100644
--- a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README.md	
+++ b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README.md	
@@ -105,9 +105,6 @@ $$
 #### Python3
 
 ```python
-from sortedcontainers import SortedSet
-
-
 class Solution:
     def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
         m, n = len(grid), len(grid[0])
diff --git a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README_EN.md b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README_EN.md
index 0163f634248d2..44014b6df28fa 100644
--- a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README_EN.md	
+++ b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/README_EN.md	
@@ -101,9 +101,6 @@ The time complexity is $O(m \times n \times \min(m, n))$, and the space complexi
 #### Python3
 
 ```python
-from sortedcontainers import SortedSet
-
-
 class Solution:
     def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
         m, n = len(grid), len(grid[0])
diff --git a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/Solution.py b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/Solution.py
index ba5346da4d19a..a3a4f905f448a 100644
--- a/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/Solution.py	
+++ b/solution/1800-1899/1878.Get Biggest Three Rhombus Sums in a Grid/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedSet
-
-
 class Solution:
     def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
         m, n = len(grid), len(grid[0])
diff --git a/solution/1900-1999/1902.Depth of BST Given Insertion Order/README.md b/solution/1900-1999/1902.Depth of BST Given Insertion Order/README.md
index 64fa02a9f62b0..161646f9e70f0 100644
--- a/solution/1900-1999/1902.Depth of BST Given Insertion Order/README.md	
+++ b/solution/1900-1999/1902.Depth of BST Given Insertion Order/README.md	
@@ -90,9 +90,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def maxDepthBST(self, order: List[int]) -> int:
         sd = SortedDict({0: 0, inf: 0, order[0]: 1})
diff --git a/solution/1900-1999/1902.Depth of BST Given Insertion Order/README_EN.md b/solution/1900-1999/1902.Depth of BST Given Insertion Order/README_EN.md
index 3119b08f1aea7..4a8e5de82e2e4 100644
--- a/solution/1900-1999/1902.Depth of BST Given Insertion Order/README_EN.md	
+++ b/solution/1900-1999/1902.Depth of BST Given Insertion Order/README_EN.md	
@@ -88,9 +88,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def maxDepthBST(self, order: List[int]) -> int:
         sd = SortedDict({0: 0, inf: 0, order[0]: 1})
diff --git a/solution/1900-1999/1902.Depth of BST Given Insertion Order/Solution.py b/solution/1900-1999/1902.Depth of BST Given Insertion Order/Solution.py
index 2e92af3b9dc83..967cc1996c5af 100644
--- a/solution/1900-1999/1902.Depth of BST Given Insertion Order/Solution.py	
+++ b/solution/1900-1999/1902.Depth of BST Given Insertion Order/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedDict
-
-
 class Solution:
     def maxDepthBST(self, order: List[int]) -> int:
         sd = SortedDict({0: 0, inf: 0, order[0]: 1})
diff --git a/solution/1900-1999/1912.Design Movie Rental System/README.md b/solution/1900-1999/1912.Design Movie Rental System/README.md
index e74d1c1ad4bda..696e109000383 100644
--- a/solution/1900-1999/1912.Design Movie Rental System/README.md	
+++ b/solution/1900-1999/1912.Design Movie Rental System/README.md	
@@ -94,9 +94,6 @@ movieRentingSystem.search(2);  // 返回 [0, 1] 。商店 0 和 1 有未借出
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MovieRentingSystem:
     def __init__(self, n: int, entries: List[List[int]]):
         self.unrented = collections.defaultdict(SortedList)  # {movie: (price, shop)}
diff --git a/solution/1900-1999/1912.Design Movie Rental System/README_EN.md b/solution/1900-1999/1912.Design Movie Rental System/README_EN.md
index bcd3e54891b5f..b4b3e8c5c2ef4 100644
--- a/solution/1900-1999/1912.Design Movie Rental System/README_EN.md	
+++ b/solution/1900-1999/1912.Design Movie Rental System/README_EN.md	
@@ -92,9 +92,6 @@ movieRentingSystem.search(2);  // return [0, 1]. Movies of ID 2 are unrented at
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class MovieRentingSystem:
     def __init__(self, n: int, entries: List[List[int]]):
         self.unrented = collections.defaultdict(SortedList)  # {movie: (price, shop)}
diff --git a/solution/1900-1999/1912.Design Movie Rental System/Solution.py b/solution/1900-1999/1912.Design Movie Rental System/Solution.py
index 3f309835db942..fe1d482225471 100644
--- a/solution/1900-1999/1912.Design Movie Rental System/Solution.py	
+++ b/solution/1900-1999/1912.Design Movie Rental System/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class MovieRentingSystem:
     def __init__(self, n: int, entries: List[List[int]]):
         self.unrented = collections.defaultdict(SortedList)  # {movie: (price, shop)}
diff --git a/solution/1900-1999/1982.Find Array Given Subset Sums/README.md b/solution/1900-1999/1982.Find Array Given Subset Sums/README.md
index d93a7fc193a73..f1c0697c62d8b 100644
--- a/solution/1900-1999/1982.Find Array Given Subset Sums/README.md	
+++ b/solution/1900-1999/1982.Find Array Given Subset Sums/README.md	
@@ -85,9 +85,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def recoverArray(self, n: int, sums: List[int]) -> List[int]:
         m = -min(sums)
diff --git a/solution/1900-1999/1982.Find Array Given Subset Sums/README_EN.md b/solution/1900-1999/1982.Find Array Given Subset Sums/README_EN.md
index ac4ec35f9d98c..91e099a879417 100644
--- a/solution/1900-1999/1982.Find Array Given Subset Sums/README_EN.md	
+++ b/solution/1900-1999/1982.Find Array Given Subset Sums/README_EN.md	
@@ -83,9 +83,6 @@ Note that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def recoverArray(self, n: int, sums: List[int]) -> List[int]:
         m = -min(sums)
diff --git a/solution/1900-1999/1982.Find Array Given Subset Sums/Solution.py b/solution/1900-1999/1982.Find Array Given Subset Sums/Solution.py
index 061099696f162..0edad4d5b0cd4 100644
--- a/solution/1900-1999/1982.Find Array Given Subset Sums/Solution.py	
+++ b/solution/1900-1999/1982.Find Array Given Subset Sums/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def recoverArray(self, n: int, sums: List[int]) -> List[int]:
         m = -min(sums)
diff --git a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README.md b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README.md
index 08b1f1e3c7700..35a8bcef59202 100644
--- a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README.md	
+++ b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README.md	
@@ -322,9 +322,6 @@ function subarraysWithMoreZerosThanOnes(nums: number[]): number {
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def subarraysWithMoreZerosThanOnes(self, nums: List[int]) -> int:
         sl = SortedList([0])
diff --git a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README_EN.md b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README_EN.md
index 05a7b8d838d59..2c7c920702e35 100644
--- a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README_EN.md	
+++ b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/README_EN.md	
@@ -323,9 +323,6 @@ function subarraysWithMoreZerosThanOnes(nums: number[]): number {
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def subarraysWithMoreZerosThanOnes(self, nums: List[int]) -> int:
         sl = SortedList([0])
diff --git a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/Solution2.py b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/Solution2.py
index 4d104814ad6eb..a8e5f2a8d0d54 100644
--- a/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/Solution2.py	
+++ b/solution/2000-2099/2031.Count Subarrays With More Ones Than Zeros/Solution2.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def subarraysWithMoreZerosThanOnes(self, nums: List[int]) -> int:
         sl = SortedList([0])
diff --git a/solution/2000-2099/2034.Stock Price Fluctuation/README.md b/solution/2000-2099/2034.Stock Price Fluctuation/README.md
index 2086a63f83136..5bb6c0b886107 100644
--- a/solution/2000-2099/2034.Stock Price Fluctuation/README.md	
+++ b/solution/2000-2099/2034.Stock Price Fluctuation/README.md	
@@ -106,9 +106,6 @@ stockPrice.minimum();     // 返回 2 ,最低价格时间戳为 4 ,价格为
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class StockPrice:
     def __init__(self):
         self.d = {}
diff --git a/solution/2000-2099/2034.Stock Price Fluctuation/README_EN.md b/solution/2000-2099/2034.Stock Price Fluctuation/README_EN.md
index efb87ad3aa4f5..1ae071651d160 100644
--- a/solution/2000-2099/2034.Stock Price Fluctuation/README_EN.md	
+++ b/solution/2000-2099/2034.Stock Price Fluctuation/README_EN.md	
@@ -105,9 +105,6 @@ The space complexity is $O(n)$, where $n$ is the number of `update` operations.
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class StockPrice:
     def __init__(self):
         self.d = {}
diff --git a/solution/2000-2099/2034.Stock Price Fluctuation/Solution.py b/solution/2000-2099/2034.Stock Price Fluctuation/Solution.py
index f077be733a49e..765f653d08860 100644
--- a/solution/2000-2099/2034.Stock Price Fluctuation/Solution.py	
+++ b/solution/2000-2099/2034.Stock Price Fluctuation/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class StockPrice:
     def __init__(self):
         self.d = {}
diff --git a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README.md b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README.md
index c24b59d52721f..c57f50dce612f 100644
--- a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README.md	
+++ b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README.md	
@@ -113,9 +113,6 @@ tracker.get();              // 从好到坏的景点为:branford, orlando, alp
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class SORTracker:
 
     def __init__(self):
diff --git a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README_EN.md b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README_EN.md
index 43359b58f43a8..b6672517800f6 100644
--- a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README_EN.md	
+++ b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/README_EN.md	
@@ -111,9 +111,6 @@ The time complexity of each operation is $O(\log n)$, where $n$ is the number of
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class SORTracker:
 
     def __init__(self):
diff --git a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/Solution.py b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/Solution.py
index 120880a8304ce..3b65eab131ddd 100644
--- a/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/Solution.py	
+++ b/solution/2100-2199/2102.Sequentially Ordinal Rank Tracker/Solution.py	
@@ -1,8 +1,4 @@
-from sortedcontainers import SortedList
-
-
 class SORTracker:
-
     def __init__(self):
         self.sl = SortedList()
         self.i = -1
diff --git a/solution/2300-2399/2336.Smallest Number in Infinite Set/README.md b/solution/2300-2399/2336.Smallest Number in Infinite Set/README.md
index ba66a9522f618..3c21e51362f7d 100644
--- a/solution/2300-2399/2336.Smallest Number in Infinite Set/README.md	
+++ b/solution/2300-2399/2336.Smallest Number in Infinite Set/README.md	
@@ -91,9 +91,6 @@ smallestInfiniteSet.popSmallest(); // 返回 5 ,并将其从集合中移除。
 #### Python3
 
 ```python
-from sortedcontainers import SortedSet
-
-
 class SmallestInfiniteSet:
     def __init__(self):
         self.s = SortedSet(range(1, 1001))
diff --git a/solution/2300-2399/2336.Smallest Number in Infinite Set/README_EN.md b/solution/2300-2399/2336.Smallest Number in Infinite Set/README_EN.md
index c047aa8ecf98c..1ba285bdf8729 100644
--- a/solution/2300-2399/2336.Smallest Number in Infinite Set/README_EN.md	
+++ b/solution/2300-2399/2336.Smallest Number in Infinite Set/README_EN.md	
@@ -90,9 +90,6 @@ The space complexity is $O(n)$.
 #### Python3
 
 ```python
-from sortedcontainers import SortedSet
-
-
 class SmallestInfiniteSet:
     def __init__(self):
         self.s = SortedSet(range(1, 1001))
diff --git a/solution/2300-2399/2336.Smallest Number in Infinite Set/Solution.py b/solution/2300-2399/2336.Smallest Number in Infinite Set/Solution.py
index e6be6e00ce732..fa35f9f4ac7a8 100644
--- a/solution/2300-2399/2336.Smallest Number in Infinite Set/Solution.py	
+++ b/solution/2300-2399/2336.Smallest Number in Infinite Set/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedSet
-
-
 class SmallestInfiniteSet:
     def __init__(self):
         self.s = SortedSet(range(1, 1001))
diff --git a/solution/2300-2399/2349.Design a Number Container System/README.md b/solution/2300-2399/2349.Design a Number Container System/README.md
index 0de3381c84616..be2105e863cce 100644
--- a/solution/2300-2399/2349.Design a Number Container System/README.md	
+++ b/solution/2300-2399/2349.Design a Number Container System/README.md	
@@ -89,9 +89,6 @@ nc.find(10); // 数字 10 所在下标为 2 ,3 和 5 。最小下标为 2 ,
 #### Python3
 
 ```python
-from sortedcontainers import SortedSet
-
-
 class NumberContainers:
 
     def __init__(self):
diff --git a/solution/2300-2399/2349.Design a Number Container System/README_EN.md b/solution/2300-2399/2349.Design a Number Container System/README_EN.md
index 8b0950666fad4..8480f11edb6db 100644
--- a/solution/2300-2399/2349.Design a Number Container System/README_EN.md	
+++ b/solution/2300-2399/2349.Design a Number Container System/README_EN.md	
@@ -54,7 +54,7 @@ nc.change(1, 10); // Your container at index 1 will be filled with number 10.
 nc.change(3, 10); // Your container at index 3 will be filled with number 10.
 nc.change(5, 10); // Your container at index 5 will be filled with number 10.
 nc.find(10); // Number 10 is at the indices 1, 2, 3, and 5. Since the smallest index that is filled with 10 is 1, we return 1.
-nc.change(1, 20); // Your container at index 1 will be filled with number 20. Note that index 1 was filled with 10 and then replaced with 20. 
+nc.change(1, 20); // Your container at index 1 will be filled with number 20. Note that index 1 was filled with 10 and then replaced with 20.
 nc.find(10); // Number 10 is at the indices 2, 3, and 5. The smallest index that is filled with 10 is 2. Therefore, we return 2.
 
@@ -87,9 +87,6 @@ The space complexity is $O(n)$, where $n$ is the number of numbers. #### Python3 ```python -from sortedcontainers import SortedSet - - class NumberContainers: def __init__(self): diff --git a/solution/2300-2399/2349.Design a Number Container System/Solution.py b/solution/2300-2399/2349.Design a Number Container System/Solution.py index 8cba7dc3ccb9c..5407f949f01f2 100644 --- a/solution/2300-2399/2349.Design a Number Container System/Solution.py +++ b/solution/2300-2399/2349.Design a Number Container System/Solution.py @@ -1,8 +1,4 @@ -from sortedcontainers import SortedSet - - class NumberContainers: - def __init__(self): self.d = {} self.g = defaultdict(SortedSet) diff --git a/solution/2300-2399/2353.Design a Food Rating System/README.md b/solution/2300-2399/2353.Design a Food Rating System/README.md index 953968ce47fe8..2ac1d87b901d4 100644 --- a/solution/2300-2399/2353.Design a Food Rating System/README.md +++ b/solution/2300-2399/2353.Design a Food Rating System/README.md @@ -100,9 +100,6 @@ foodRatings.highestRated("japanese"); // 返回 "ramen" #### Python3 ```python -from sortedcontainers import SortedSet - - class FoodRatings: def __init__(self, foods: List[str], cuisines: List[str], ratings: List[int]): self.mp = {} diff --git a/solution/2300-2399/2353.Design a Food Rating System/README_EN.md b/solution/2300-2399/2353.Design a Food Rating System/README_EN.md index a76a43ed232ad..4c0395a2a941e 100644 --- a/solution/2300-2399/2353.Design a Food Rating System/README_EN.md +++ b/solution/2300-2399/2353.Design a Food Rating System/README_EN.md @@ -99,9 +99,6 @@ foodRatings.highestRated("japanese"); // return "ramen" #### Python3 ```python -from sortedcontainers import SortedSet - - class FoodRatings: def __init__(self, foods: List[str], cuisines: List[str], ratings: List[int]): self.mp = {} diff --git a/solution/2300-2399/2353.Design a Food Rating System/Solution.py b/solution/2300-2399/2353.Design a Food Rating System/Solution.py index fae8087781918..eea8494e76570 100644 --- a/solution/2300-2399/2353.Design a Food Rating System/Solution.py +++ b/solution/2300-2399/2353.Design a Food Rating System/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class FoodRatings: def __init__(self, foods: List[str], cuisines: List[str], ratings: List[int]): self.mp = {} diff --git a/solution/2400-2499/2454.Next Greater Element IV/README.md b/solution/2400-2499/2454.Next Greater Element IV/README.md index 347666767adcf..2142850f3a155 100644 --- a/solution/2400-2499/2454.Next Greater Element IV/README.md +++ b/solution/2400-2499/2454.Next Greater Element IV/README.md @@ -94,9 +94,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def secondGreaterElement(self, nums: List[int]) -> List[int]: arr = [(x, i) for i, x in enumerate(nums)] diff --git a/solution/2400-2499/2454.Next Greater Element IV/README_EN.md b/solution/2400-2499/2454.Next Greater Element IV/README_EN.md index c9993558b5303..1a2a598e292b1 100644 --- a/solution/2400-2499/2454.Next Greater Element IV/README_EN.md +++ b/solution/2400-2499/2454.Next Greater Element IV/README_EN.md @@ -92,9 +92,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def secondGreaterElement(self, nums: List[int]) -> List[int]: arr = [(x, i) for i, x in enumerate(nums)] diff --git a/solution/2400-2499/2454.Next Greater Element IV/Solution.py b/solution/2400-2499/2454.Next Greater Element IV/Solution.py index e0da6506e11fe..5dad5e7463939 100644 --- a/solution/2400-2499/2454.Next Greater Element IV/Solution.py +++ b/solution/2400-2499/2454.Next Greater Element IV/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def secondGreaterElement(self, nums: List[int]) -> List[int]: arr = [(x, i) for i, x in enumerate(nums)] diff --git a/solution/2500-2599/2502.Design Memory Allocator/README.md b/solution/2500-2599/2502.Design Memory Allocator/README.md index dbfed0eb914ab..5dcd9a497cef2 100644 --- a/solution/2500-2599/2502.Design Memory Allocator/README.md +++ b/solution/2500-2599/2502.Design Memory Allocator/README.md @@ -295,9 +295,6 @@ func (this *Allocator) Free(mID int) (ans int) { #### Python3 ```python -from sortedcontainers import SortedList - - class Allocator: def __init__(self, n: int): self.sl = SortedList([(-1, -1), (n, n)]) diff --git a/solution/2500-2599/2502.Design Memory Allocator/README_EN.md b/solution/2500-2599/2502.Design Memory Allocator/README_EN.md index bc95203930d2a..a41deca08edc9 100644 --- a/solution/2500-2599/2502.Design Memory Allocator/README_EN.md +++ b/solution/2500-2599/2502.Design Memory Allocator/README_EN.md @@ -293,9 +293,6 @@ The time complexity is $O(q \log n)$, and the space complexity is $O(n)$, where #### Python3 ```python -from sortedcontainers import SortedList - - class Allocator: def __init__(self, n: int): self.sl = SortedList([(-1, -1), (n, n)]) diff --git a/solution/2500-2599/2502.Design Memory Allocator/Solution2.py b/solution/2500-2599/2502.Design Memory Allocator/Solution2.py index 22270a882204e..3f2806f449a60 100644 --- a/solution/2500-2599/2502.Design Memory Allocator/Solution2.py +++ b/solution/2500-2599/2502.Design Memory Allocator/Solution2.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Allocator: def __init__(self, n: int): self.sl = SortedList([(-1, -1), (n, n)]) diff --git a/solution/2500-2599/2590.Design a Todo List/README.md b/solution/2500-2599/2590.Design a Todo List/README.md index 6455bca8ef8a2..c66941f981134 100644 --- a/solution/2500-2599/2590.Design a Todo List/README.md +++ b/solution/2500-2599/2590.Design a Todo List/README.md @@ -44,17 +44,17 @@ tags: [null, 1, 2, ["Task1", "Task2"], [], 3, ["Task3", "Task2"], null, null, ["Task3"], ["Task3", "Task1"]] 解释 -TodoList todoList = new TodoList(); -todoList.addTask(1, "Task1", 50, []); // 返回1。为ID为1的用户添加一个新任务。 -todoList.addTask(1, "Task2", 100, ["P1"]); // 返回2。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 -todoList.getAllTasks(1); // 返回["Task1", "Task2"]。用户1目前有两个未完成的任务。 -todoList.getAllTasks(5); // 返回[]。用户5目前没有任务。 -todoList.addTask(1, "Task3", 30, ["P1"]); // 返回3。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 -todoList.getTasksForTag(1, "P1"); // 返回["Task3", "Task2"]。返回ID为1的用户未完成的带有“P1”标签的任务。 -todoList.completeTask(5, 1); // 不做任何操作,因为任务1不属于用户5。 -todoList.completeTask(1, 2); // 将任务2标记为已完成。 -todoList.getTasksForTag(1, "P1"); // 返回["Task3"]。返回ID为1的用户未完成的带有“P1”标签的任务。 - // 注意,现在不包括 “Task2” ,因为它已经被标记为已完成。 +TodoList todoList = new TodoList(); +todoList.addTask(1, "Task1", 50, []); // 返回1。为ID为1的用户添加一个新任务。 +todoList.addTask(1, "Task2", 100, ["P1"]); // 返回2。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 +todoList.getAllTasks(1); // 返回["Task1", "Task2"]。用户1目前有两个未完成的任务。 +todoList.getAllTasks(5); // 返回[]。用户5目前没有任务。 +todoList.addTask(1, "Task3", 30, ["P1"]); // 返回3。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 +todoList.getTasksForTag(1, "P1"); // 返回["Task3", "Task2"]。返回ID为1的用户未完成的带有“P1”标签的任务。 +todoList.completeTask(5, 1); // 不做任何操作,因为任务1不属于用户5。 +todoList.completeTask(1, 2); // 将任务2标记为已完成。 +todoList.getTasksForTag(1, "P1"); // 返回["Task3"]。返回ID为1的用户未完成的带有“P1”标签的任务。 + // 注意,现在不包括 “Task2” ,因为它已经被标记为已完成。 todoList.getAllTasks(1); // 返回["Task3", "Task1"]。用户1现在有两个未完成的任务。
@@ -98,9 +98,6 @@ todoList.getAllTasks(1); // 返回["Task3", "Task1"]。用户1现在有两个未 #### Python3 ```python -from sortedcontainers import SortedList - - class TodoList: def __init__(self): self.i = 1 diff --git a/solution/2500-2599/2590.Design a Todo List/README_EN.md b/solution/2500-2599/2590.Design a Todo List/README_EN.md index bc443e5dee35c..51c3bd391b362 100644 --- a/solution/2500-2599/2590.Design a Todo List/README_EN.md +++ b/solution/2500-2599/2590.Design a Todo List/README_EN.md @@ -96,9 +96,6 @@ The space complexity is $O(n)$. Where $n$ is the number of all tasks. #### Python3 ```python -from sortedcontainers import SortedList - - class TodoList: def __init__(self): self.i = 1 diff --git a/solution/2500-2599/2590.Design a Todo List/Solution.py b/solution/2500-2599/2590.Design a Todo List/Solution.py index a06e06dd4a26f..b10def8293b59 100644 --- a/solution/2500-2599/2590.Design a Todo List/Solution.py +++ b/solution/2500-2599/2590.Design a Todo List/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class TodoList: def __init__(self): self.i = 1 diff --git a/solution/2600-2699/2612.Minimum Reverse Operations/README.md b/solution/2600-2699/2612.Minimum Reverse Operations/README.md index 20b78a7dc434c..c616eafebb255 100644 --- a/solution/2600-2699/2612.Minimum Reverse Operations/README.md +++ b/solution/2600-2699/2612.Minimum Reverse Operations/README.md @@ -113,9 +113,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def minReverseOperations( self, n: int, p: int, banned: List[int], k: int diff --git a/solution/2600-2699/2612.Minimum Reverse Operations/README_EN.md b/solution/2600-2699/2612.Minimum Reverse Operations/README_EN.md index 072c549709196..31d61dd3a3fbe 100644 --- a/solution/2600-2699/2612.Minimum Reverse Operations/README_EN.md +++ b/solution/2600-2699/2612.Minimum Reverse Operations/README_EN.md @@ -122,9 +122,6 @@ The time complexity is $O(n \times \log n)$ and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedSet - - class Solution: def minReverseOperations( self, n: int, p: int, banned: List[int], k: int diff --git a/solution/2600-2699/2612.Minimum Reverse Operations/Solution.py b/solution/2600-2699/2612.Minimum Reverse Operations/Solution.py index e3b946f93e734..fbca135d851c6 100644 --- a/solution/2600-2699/2612.Minimum Reverse Operations/Solution.py +++ b/solution/2600-2699/2612.Minimum Reverse Operations/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedSet - - class Solution: def minReverseOperations( self, n: int, p: int, banned: List[int], k: int diff --git a/solution/2600-2699/2653.Sliding Subarray Beauty/README.md b/solution/2600-2699/2653.Sliding Subarray Beauty/README.md index 96ca078500a57..ba429aa752535 100644 --- a/solution/2600-2699/2653.Sliding Subarray Beauty/README.md +++ b/solution/2600-2699/2653.Sliding Subarray Beauty/README.md @@ -119,9 +119,6 @@ class Solution: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]: sl = SortedList(nums[:k]) diff --git a/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md b/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md index 33594f7b46342..0de9ec290eff7 100644 --- a/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md +++ b/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md @@ -38,7 +38,7 @@ tags:
 Input: nums = [1,-1,-3,-2,3], k = 3, x = 2
 Output: [-1,-2,-2]
-Explanation: There are 3 subarrays with size k = 3. 
+Explanation: There are 3 subarrays with size k = 3.
 The first subarray is [1, -1, -3] and the 2nd smallest negative integer is -1. 
 The second subarray is [-1, -3, -2] and the 2nd smallest negative integer is -2. 
 The third subarray is [-3, -2, 3] and the 2nd smallest negative integer is -2.
@@ -120,9 +120,6 @@ class Solution: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]: sl = SortedList(nums[:k]) diff --git a/solution/2600-2699/2659.Make Array Empty/README.md b/solution/2600-2699/2659.Make Array Empty/README.md index f2b9c92358653..054240c78888a 100644 --- a/solution/2600-2699/2659.Make Array Empty/README.md +++ b/solution/2600-2699/2659.Make Array Empty/README.md @@ -176,9 +176,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def countOperationsToEmptyArray(self, nums: List[int]) -> int: pos = {x: i for i, x in enumerate(nums)} diff --git a/solution/2600-2699/2659.Make Array Empty/README_EN.md b/solution/2600-2699/2659.Make Array Empty/README_EN.md index a81bbd04fcd5b..1272b8c64ce1d 100644 --- a/solution/2600-2699/2659.Make Array Empty/README_EN.md +++ b/solution/2600-2699/2659.Make Array Empty/README_EN.md @@ -170,9 +170,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def countOperationsToEmptyArray(self, nums: List[int]) -> int: pos = {x: i for i, x in enumerate(nums)} diff --git a/solution/2600-2699/2659.Make Array Empty/Solution.py b/solution/2600-2699/2659.Make Array Empty/Solution.py index 34c567d12baa1..d940cdd66a139 100644 --- a/solution/2600-2699/2659.Make Array Empty/Solution.py +++ b/solution/2600-2699/2659.Make Array Empty/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def countOperationsToEmptyArray(self, nums: List[int]) -> int: pos = {x: i for i, x in enumerate(nums)} diff --git a/solution/2700-2799/2762.Continuous Subarrays/README.md b/solution/2700-2799/2762.Continuous Subarrays/README.md index 3953238032644..84852f179afe1 100644 --- a/solution/2700-2799/2762.Continuous Subarrays/README.md +++ b/solution/2700-2799/2762.Continuous Subarrays/README.md @@ -91,9 +91,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def continuousSubarrays(self, nums: List[int]) -> int: ans = i = 0 diff --git a/solution/2700-2799/2762.Continuous Subarrays/README_EN.md b/solution/2700-2799/2762.Continuous Subarrays/README_EN.md index 1a847f01bdcd2..258846bd742cb 100644 --- a/solution/2700-2799/2762.Continuous Subarrays/README_EN.md +++ b/solution/2700-2799/2762.Continuous Subarrays/README_EN.md @@ -39,7 +39,7 @@ tags:
 Input: nums = [5,4,2,4]
 Output: 8
-Explanation: 
+Explanation:
 Continuous subarray of size 1: [5], [4], [2], [4].
 Continuous subarray of size 2: [5,4], [4,2], [2,4].
 Continuous subarray of size 3: [4,2,4].
@@ -55,7 +55,7 @@ It can be shown that there are no more continuous subarrays.
 
 Input: nums = [1,2,3]
 Output: 6
-Explanation: 
+Explanation:
 Continuous subarray of size 1: [1], [2], [3].
 Continuous subarray of size 2: [1,2], [2,3].
 Continuous subarray of size 3: [1,2,3].
@@ -91,9 +91,6 @@ The time complexity is $O(n \times \log n)$ and the space complexity is $O(n)$,
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def continuousSubarrays(self, nums: List[int]) -> int:
         ans = i = 0
diff --git a/solution/2700-2799/2762.Continuous Subarrays/Solution.py b/solution/2700-2799/2762.Continuous Subarrays/Solution.py
index 8089ee16dd76b..ffa82d254100b 100644
--- a/solution/2700-2799/2762.Continuous Subarrays/Solution.py	
+++ b/solution/2700-2799/2762.Continuous Subarrays/Solution.py	
@@ -1,6 +1,3 @@
-from sortedcontainers import SortedList
-
-
 class Solution:
     def continuousSubarrays(self, nums: List[int]) -> int:
         ans = i = 0
diff --git a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README.md b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README.md
index e443e54314275..41459fd817948 100644
--- a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README.md	
+++ b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README.md	
@@ -94,9 +94,6 @@ tags:
 #### Python3
 
 ```python
-from sortedcontainers import SortedList
-
-
 class Solution:
     def sumImbalanceNumbers(self, nums: List[int]) -> int:
         n = len(nums)
diff --git a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md
index 4259e60bb808b..0243dafa27604 100644
--- a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md	
+++ b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md	
@@ -43,7 +43,7 @@ tags:
 - Subarray [3, 1] with an imbalance number of 1.
 - Subarray [3, 1, 4] with an imbalance number of 1.
 - Subarray [1, 4] with an imbalance number of 1.
-The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3. 
+The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3.
 

Example 2:

@@ -55,8 +55,8 @@ The imbalance number of all other subarrays is 0. Hence, the sum of imbalance nu - Subarray [1, 3] with an imbalance number of 1. - Subarray [1, 3, 3] with an imbalance number of 1. - Subarray [1, 3, 3, 3] with an imbalance number of 1. -- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2. -- Subarray [3, 3, 3, 5] with an imbalance number of 1. +- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2. +- Subarray [3, 3, 3, 5] with an imbalance number of 1. - Subarray [3, 3, 5] with an imbalance number of 1. - Subarray [3, 5] with an imbalance number of 1. The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 8.
@@ -94,9 +94,6 @@ The time complexity is $O(n^2 \times \log n)$ and the space complexity is $O(n)$ #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def sumImbalanceNumbers(self, nums: List[int]) -> int: n = len(nums) diff --git a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/Solution.py b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/Solution.py index 776fdc1764d7a..6c372abf9c553 100644 --- a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/Solution.py +++ b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def sumImbalanceNumbers(self, nums: List[int]) -> int: n = len(nums) diff --git a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README.md b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README.md index 5e57054fd1f25..2f9ce5de6cf77 100644 --- a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README.md +++ b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README.md @@ -89,9 +89,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minAbsoluteDifference(self, nums: List[int], x: int) -> int: sl = SortedList() diff --git a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md index 89819908e0154..fb1c71f35d61f 100644 --- a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md +++ b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md @@ -34,8 +34,8 @@ tags:
 Input: nums = [4,3,2,4], x = 2
 Output: 0
-Explanation: We can select nums[0] = 4 and nums[3] = 4. 
-They are at least 2 indices apart, and their absolute difference is the minimum, 0. 
+Explanation: We can select nums[0] = 4 and nums[3] = 4.
+They are at least 2 indices apart, and their absolute difference is the minimum, 0.
 It can be shown that 0 is the optimal answer.
 
@@ -87,9 +87,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$. #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minAbsoluteDifference(self, nums: List[int], x: int) -> int: sl = SortedList() diff --git a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/Solution.py b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/Solution.py index 5b0f30f929f7d..335788dd40c0e 100644 --- a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/Solution.py +++ b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def minAbsoluteDifference(self, nums: List[int], x: int) -> int: sl = SortedList() diff --git a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README.md b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README.md index 9a301a2be381f..69a908b067301 100644 --- a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README.md +++ b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README.md @@ -96,9 +96,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minimumCost(self, nums: List[int], k: int, dist: int) -> int: def l2r(): diff --git a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README_EN.md b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README_EN.md index 2bfd3c2c793ce..f8f162ad556af 100644 --- a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README_EN.md +++ b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/README_EN.md @@ -94,9 +94,6 @@ The time complexity is $O(n \times \log \textit{dist})$, and the space complexit #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minimumCost(self, nums: List[int], k: int, dist: int) -> int: def l2r(): diff --git a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/Solution.py b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/Solution.py index 7a7384a025f33..6914ac2aa0cdc 100644 --- a/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/Solution.py +++ b/solution/3000-3099/3013.Divide an Array Into Subarrays With Minimum Cost II/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def minimumCost(self, nums: List[int], k: int, dist: int) -> int: def l2r(): diff --git a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README.md b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README.md index 19799cab9aef9..fdd2edd56b2ef 100644 --- a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README.md +++ b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README.md @@ -154,9 +154,6 @@ class Solution: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def resultArray(self, nums: List[int]) -> List[int]: arr1 = [nums[0]] diff --git a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README_EN.md b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README_EN.md index 4f45a20cf1aac..888fb409c77f9 100644 --- a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README_EN.md +++ b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/README_EN.md @@ -152,9 +152,6 @@ class Solution: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def resultArray(self, nums: List[int]) -> List[int]: arr1 = [nums[0]] diff --git a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/Solution2.py b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/Solution2.py index 0896abb3029f5..03e8ae66f5089 100644 --- a/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/Solution2.py +++ b/solution/3000-3099/3072.Distribute Elements Into Two Arrays II/Solution2.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def resultArray(self, nums: List[int]) -> List[int]: arr1 = [nums[0]] diff --git a/solution/3000-3099/3073.Maximum Increasing Triplet Value/README.md b/solution/3000-3099/3073.Maximum Increasing Triplet Value/README.md index 3d5badf69696f..bd63ffeb5252e 100644 --- a/solution/3000-3099/3073.Maximum Increasing Triplet Value/README.md +++ b/solution/3000-3099/3073.Maximum Increasing Triplet Value/README.md @@ -75,9 +75,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def maximumTripletValue(self, nums: List[int]) -> int: n = len(nums) diff --git a/solution/3000-3099/3073.Maximum Increasing Triplet Value/README_EN.md b/solution/3000-3099/3073.Maximum Increasing Triplet Value/README_EN.md index 99eaf81e6d9a9..26c3ed0a6b839 100644 --- a/solution/3000-3099/3073.Maximum Increasing Triplet Value/README_EN.md +++ b/solution/3000-3099/3073.Maximum Increasing Triplet Value/README_EN.md @@ -80,9 +80,6 @@ The time complexity is $O(n \times \log n)$, and the space complexity is $O(n)$, #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def maximumTripletValue(self, nums: List[int]) -> int: n = len(nums) diff --git a/solution/3000-3099/3073.Maximum Increasing Triplet Value/Solution.py b/solution/3000-3099/3073.Maximum Increasing Triplet Value/Solution.py index 3433d42888733..d3414dfdb1880 100644 --- a/solution/3000-3099/3073.Maximum Increasing Triplet Value/Solution.py +++ b/solution/3000-3099/3073.Maximum Increasing Triplet Value/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def maximumTripletValue(self, nums: List[int]) -> int: n = len(nums) diff --git a/solution/3100-3199/3102.Minimize Manhattan Distances/README.md b/solution/3100-3199/3102.Minimize Manhattan Distances/README.md index c39507a1b13b3..f29737503efab 100644 --- a/solution/3100-3199/3102.Minimize Manhattan Distances/README.md +++ b/solution/3100-3199/3102.Minimize Manhattan Distances/README.md @@ -102,9 +102,6 @@ $$ #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minimumDistance(self, points: List[List[int]]) -> int: sl1 = SortedList() diff --git a/solution/3100-3199/3102.Minimize Manhattan Distances/README_EN.md b/solution/3100-3199/3102.Minimize Manhattan Distances/README_EN.md index 14ffe4e189cb6..2c2f33f670122 100644 --- a/solution/3100-3199/3102.Minimize Manhattan Distances/README_EN.md +++ b/solution/3100-3199/3102.Minimize Manhattan Distances/README_EN.md @@ -112,9 +112,6 @@ The time complexity is $O(n \log n)$, and the space complexity is $O(n)$. Here, #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def minimumDistance(self, points: List[List[int]]) -> int: sl1 = SortedList() diff --git a/solution/3100-3199/3102.Minimize Manhattan Distances/Solution.py b/solution/3100-3199/3102.Minimize Manhattan Distances/Solution.py index a03ba42c01950..71c678ab1d3a2 100644 --- a/solution/3100-3199/3102.Minimize Manhattan Distances/Solution.py +++ b/solution/3100-3199/3102.Minimize Manhattan Distances/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def minimumDistance(self, points: List[List[int]]) -> int: sl1 = SortedList() diff --git a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README.md b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README.md index d65fd14842d73..6cb2ff31b4a2d 100644 --- a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README.md +++ b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README.md @@ -401,7 +401,6 @@ class Solution: ```java import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { diff --git a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README_EN.md b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README_EN.md index c164c08fb9efa..2dc43e1f63aab 100644 --- a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README_EN.md +++ b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/README_EN.md @@ -399,7 +399,6 @@ class Solution: ```java import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { diff --git a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/Solution3.java b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/Solution3.java index 392df1d774587..65853f2c6e045 100644 --- a/solution/3100-3199/3180.Maximum Total Reward Using Operations I/Solution3.java +++ b/solution/3100-3199/3180.Maximum Total Reward Using Operations I/Solution3.java @@ -1,5 +1,4 @@ import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { @@ -12,4 +11,4 @@ public int maxTotalReward(int[] rewardValues) { } return f.bitLength() - 1; } -} \ No newline at end of file +} diff --git a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README.md b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README.md index 4b83543ce3bb3..faf7787c30639 100644 --- a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README.md +++ b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README.md @@ -112,7 +112,6 @@ class Solution: ```java import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { diff --git a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README_EN.md b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README_EN.md index 765a9beeb5e37..0517f49b60df0 100644 --- a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README_EN.md +++ b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/README_EN.md @@ -110,7 +110,6 @@ class Solution: ```java import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { diff --git a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/Solution.java b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/Solution.java index 392df1d774587..65853f2c6e045 100644 --- a/solution/3100-3199/3181.Maximum Total Reward Using Operations II/Solution.java +++ b/solution/3100-3199/3181.Maximum Total Reward Using Operations II/Solution.java @@ -1,5 +1,4 @@ import java.math.BigInteger; -import java.util.Arrays; class Solution { public int maxTotalReward(int[] rewardValues) { @@ -12,4 +11,4 @@ public int maxTotalReward(int[] rewardValues) { } return f.bitLength() - 1; } -} \ No newline at end of file +} 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 5cf065fe6afef..f1a19b0a3e23d 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 @@ -100,9 +100,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): 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 6672fc4706bdc..11ff497d336d9 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 @@ -96,9 +96,6 @@ Similar problems: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): diff --git a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/Solution.py b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/Solution.py index f885f531a96ab..5719134adf189 100644 --- a/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/Solution.py +++ b/solution/3300-3399/3318.Find X-Sum of All K-Long Subarrays I/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): 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 bdc1c78e86c45..8f0cf43e5e1be 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 @@ -102,9 +102,6 @@ tags: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): 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 7d676552bafe8..876c9ad699ed4 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 @@ -97,9 +97,6 @@ Similar problems: #### Python3 ```python -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): diff --git a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/Solution.py b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/Solution.py index f885f531a96ab..5719134adf189 100644 --- a/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/Solution.py +++ b/solution/3300-3399/3321.Find X-Sum of All K-Long Subarrays II/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class Solution: def findXSum(self, nums: List[int], k: int, x: int) -> List[int]: def add(v: int): diff --git a/solution/3300-3399/3369.Design an Array Statistics Tracker/README.md b/solution/3300-3399/3369.Design an Array Statistics Tracker/README.md index 7b79ae1d4f69a..673e1000d4bc2 100644 --- a/solution/3300-3399/3369.Design an Array Statistics Tracker/README.md +++ b/solution/3300-3399/3369.Design an Array Statistics Tracker/README.md @@ -129,9 +129,6 @@ statisticsTracker.getMode(); // return 5 #### Python3 ```python -from sortedcontainers import SortedList - - class StatisticsTracker: def __init__(self): diff --git a/solution/3300-3399/3369.Design an Array Statistics Tracker/README_EN.md b/solution/3300-3399/3369.Design an Array Statistics Tracker/README_EN.md index 0861da2b522ad..c288e3d5d50cb 100644 --- a/solution/3300-3399/3369.Design an Array Statistics Tracker/README_EN.md +++ b/solution/3300-3399/3369.Design an Array Statistics Tracker/README_EN.md @@ -127,9 +127,6 @@ The space complexity is $O(n)$, where $n$ is the number of added numbers. #### Python3 ```python -from sortedcontainers import SortedList - - class StatisticsTracker: def __init__(self): diff --git a/solution/3300-3399/3369.Design an Array Statistics Tracker/Solution.py b/solution/3300-3399/3369.Design an Array Statistics Tracker/Solution.py index dfff4f63287c1..351ce2b8313ec 100644 --- a/solution/3300-3399/3369.Design an Array Statistics Tracker/Solution.py +++ b/solution/3300-3399/3369.Design an Array Statistics Tracker/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class StatisticsTracker: def __init__(self): self.q = deque() diff --git a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md index 488d6ce1f489f..d699f8121ed30 100644 --- a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md +++ b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md @@ -104,9 +104,6 @@ matrix3D.largestMatrix(); // 返回 3。0 到 3 的对应值都有相同数量 #### Python3 ```python -from sortedcontainers import SortedList - - class matrix3D: def __init__(self, n: int): diff --git a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md index 84eb0d8a9e8a7..675109df19dff 100644 --- a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md +++ b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md @@ -102,9 +102,6 @@ In terms of time complexity, the `setCell` and `unsetCell` methods both have a t #### Python3 ```python -from sortedcontainers import SortedList - - class matrix3D: def __init__(self, n: int): diff --git a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/Solution.py b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/Solution.py index cf25b09797800..3d9d356e6e466 100644 --- a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/Solution.py +++ b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/Solution.py @@ -1,6 +1,3 @@ -from sortedcontainers import SortedList - - class matrix3D: def __init__(self, n: int): self.g = [[[0] * n for _ in range(n)] for _ in range(n)] diff --git a/solution/3400-3499/3408.Design Task Manager/README.md b/solution/3400-3499/3408.Design Task Manager/README.md index 0d2b385d52839..db20a6a96b92f 100644 --- a/solution/3400-3499/3408.Design Task Manager/README.md +++ b/solution/3400-3499/3408.Design Task Manager/README.md @@ -91,9 +91,6 @@ taskManager.execTop(); // 返回 5 。执行用户 5 的任务 105 。 #### Python3 ```python -from sortedcontainers import SortedList - - class TaskManager: def __init__(self, tasks: List[List[int]]): diff --git a/solution/3400-3499/3408.Design Task Manager/README_EN.md b/solution/3400-3499/3408.Design Task Manager/README_EN.md index 6a6e731e8c0f2..33c2654469b79 100644 --- a/solution/3400-3499/3408.Design Task Manager/README_EN.md +++ b/solution/3400-3499/3408.Design Task Manager/README_EN.md @@ -89,9 +89,6 @@ taskManager.execTop(); // return 5. Executes task 105 for User 5. #### Python3 ```python -from sortedcontainers import SortedList - - class TaskManager: def __init__(self, tasks: List[List[int]]): diff --git a/solution/3400-3499/3408.Design Task Manager/Solution.py b/solution/3400-3499/3408.Design Task Manager/Solution.py index eb6f8cd32310d..84aa97ddf6d84 100644 --- a/solution/3400-3499/3408.Design Task Manager/Solution.py +++ b/solution/3400-3499/3408.Design Task Manager/Solution.py @@ -1,8 +1,4 @@ -from sortedcontainers import SortedList - - class TaskManager: - def __init__(self, tasks: List[List[int]]): self.d = {} self.st = SortedList()