Skip to content

[pull] main from doocs:main #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedSet


class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) -> bool:
s = SortedSet()
Expand Down
6 changes: 0 additions & 6 deletions lcof2/剑指 Offer II 058. 日程表/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ MyCalendar.book(20, 30); // returns true ,第三个日程安排可以添加到
#### Python3

```python
from sortedcontainers import SortedDict


class MyCalendar:
def __init__(self):
self.sd = SortedDict()
Expand All @@ -89,9 +86,6 @@ class MyCalendar:
#### Java

```java
import java.util.Map;
import java.util.TreeMap;

class MyCalendar {

private final TreeMap<Integer, Integer> tm = new TreeMap<>();
Expand Down
5 changes: 1 addition & 4 deletions lcof2/剑指 Offer II 058. 日程表/Solution.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.Map;
import java.util.TreeMap;

class MyCalendar {

private final TreeMap<Integer, Integer> tm = new TreeMap<>();
Expand All @@ -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);
*/
*/
3 changes: 0 additions & 3 deletions lcof2/剑指 Offer II 058. 日程表/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedDict


class MyCalendar:
def __init__(self):
self.sd = SortedDict()
Expand Down
3 changes: 0 additions & 3 deletions lcp/LCP 24. 数字游戏/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ class Solution {
#### Python3

```python
from sortedcontainers import SortedList


class Solution:
def numsGame(self, nums: List[int]) -> List[int]:
l = SortedList()
Expand Down
3 changes: 0 additions & 3 deletions lcp/LCP 24. 数字游戏/Solution2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedList


class Solution:
def numsGame(self, nums: List[int]) -> List[int]:
l = SortedList()
Expand Down
3 changes: 0 additions & 3 deletions lcp/LCP 52. 二叉搜索树染色/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions lcp/LCP 52. 二叉搜索树染色/Solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions solution/0200-0299/0220.Contains Duplicate III/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ abs(nums[i] - nums[j]) &lt;= valueDiff --&gt; abs(1 - 1) &lt;= 0
#### Python3

```python
from sortedcontainers import SortedSet


class Solution:
def containsNearbyAlmostDuplicate(
self, nums: List[int], indexDiff: int, valueDiff: int
Expand Down
3 changes: 0 additions & 3 deletions solution/0200-0299/0220.Contains Duplicate III/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions solution/0200-0299/0220.Contains Duplicate III/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedSet


class Solution:
def containsNearbyAlmostDuplicate(
self, nums: List[int], indexDiff: int, valueDiff: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class MyStack:
#### Java

```java
import java.util.Deque;

class MyStack {
private Deque<Integer> q1 = new ArrayDeque<>();
private Deque<Integer> q2 = new ArrayDeque<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class MyStack:
#### Java

```java
import java.util.Deque;

class MyStack {
private Deque<Integer> q1 = new ArrayDeque<>();
private Deque<Integer> q2 = new ArrayDeque<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.util.Deque;

class MyStack {
private Deque<Integer> q1 = new ArrayDeque<>();
private Deque<Integer> q2 = new ArrayDeque<>();
Expand Down Expand Up @@ -37,4 +35,4 @@ public boolean empty() {
* int param_2 = obj.pop();
* int param_3 = obj.top();
* boolean param_4 = obj.empty();
*/
*/
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ summaryRanges.getIntervals(); // 返回 [[1, 3], [6, 7]]
#### Python3

```python
from sortedcontainers import SortedDict


class SummaryRanges:
def __init__(self):
self.mp = SortedDict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedDict


class SummaryRanges:
def __init__(self):
self.mp = SortedDict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
3 changes: 0 additions & 3 deletions solution/0400-0499/0480.Sliding Window Median/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions solution/0400-0499/0480.Sliding Window Median/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [1,3,-1,-3,5,3,6,7], k = 3
<strong>Output:</strong> [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000]
<strong>Explanation:</strong>
<strong>Explanation:</strong>
Window position Median
--------------- -----
[<strong>1 3 -1</strong>] -3 5 3 6 7 1
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions solution/0400-0499/0480.Sliding Window Median/Solution2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedList


class Solution:
def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
l = SortedList()
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0716.Max Stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ stk.top(); // 返回 5,[<strong>5</strong>] - 栈没有改变
#### Python3

```python
from sortedcontainers import SortedList


class Node:
def __init__(self, val=0):
self.val = val
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0716.Max Stack/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ stk.top(); // return 5, [<strong><u>5</u></strong>] the stack did not change
#### Python3

```python
from sortedcontainers import SortedList


class Node:
def __init__(self, val=0):
self.val = val
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0716.Max Stack/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedList


class Node:
def __init__(self, val=0):
self.val = val
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0729.My Calendar I/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ myCalendar.book(20, 30); // return True ,这个日程安排可以添加到日
#### Python3

```python
from sortedcontainers import SortedDict


class MyCalendar:

def __init__(self):
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0729.My Calendar I/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0729.My Calendar I/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedDict


class MyCalendar:
def __init__(self):
self.sd = SortedDict()
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0731.My Calendar II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ myCalendarTwo.book(25, 55); // 返回 True,能够预定该日程,因为时
#### Python3

```python
from sortedcontainers import SortedDict


class MyCalendarTwo:

def __init__(self):
Expand Down
9 changes: 3 additions & 6 deletions solution/0700-0799/0731.My Calendar II/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ tags:

<strong>Explanation</strong>
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.
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions solution/0700-0799/0731.My Calendar II/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedDict


class MyCalendarTwo:
def __init__(self):
self.sd = SortedDict()
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0846.Hand of Straights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0846.Hand of Straights/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0846.Hand of Straights/Solution2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedDict


class Solution:
def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
if len(hand) % groupSize != 0:
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0855.Exam Room/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ examRoom.seat(); // 返回 5,学生最后坐在 5 号座位。
#### Python3

```python
from sortedcontainers import SortedList


class ExamRoom:
def __init__(self, n: int):
def dist(x):
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0855.Exam Room/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions solution/0800-0899/0855.Exam Room/Solution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sortedcontainers import SortedList


class ExamRoom:
def __init__(self, n: int):
def dist(x):
Expand Down
3 changes: 0 additions & 3 deletions solution/0900-0999/0975.Odd Even Jump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ tags:
#### Python3

```python
from sortedcontainers import SortedDict


class Solution:
def oddEvenJumps(self, arr: List[int]) -> int:
@cache
Expand Down
Loading