Skip to content

Commit 6a972f9

Browse files
committed
feat: update solutions to lc problems
* No.0253.Meeting Rooms II * No.1943.Describe the Painting
1 parent 3614710 commit 6a972f9

File tree

8 files changed

+10
-28
lines changed

8 files changed

+10
-28
lines changed

solution/0200-0299/0253.Meeting Rooms II/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<!-- 这里可写通用的实现逻辑 -->
3939

40-
差分数组
40+
**方法一:差分数组**
4141

4242
<!-- tabs:start -->
4343

@@ -52,9 +52,7 @@ class Solution:
5252
for start, end in intervals:
5353
delta[start] += 1
5454
delta[end] -= 1
55-
for i in range(len(delta) - 1):
56-
delta[i + 1] += delta[i]
57-
return max(delta)
55+
return max(accumulate(delta))
5856
```
5957

6058
### **Java**

solution/0200-0299/0253.Meeting Rooms II/README_EN.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ class Solution:
3535
for start, end in intervals:
3636
delta[start] += 1
3737
delta[end] -= 1
38-
for i in range(len(delta) - 1):
39-
delta[i + 1] += delta[i]
40-
return max(delta)
38+
return max(accumulate(delta))
4139
```
4240

4341
### **Java**

solution/0200-0299/0253.Meeting Rooms II/Solution.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ def minMeetingRooms(self, intervals: List[List[int]]) -> int:
44
for start, end in intervals:
55
delta[start] += 1
66
delta[end] -= 1
7-
for i in range(len(delta) - 1):
8-
delta[i + 1] += delta[i]
9-
return max(delta)
7+
return max(accumulate(delta))

solution/0700-0799/0798.Smallest Rotation with Highest Score/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ nums 无论怎么变化总是有 3 分。
5353

5454
<!-- 这里可写通用的实现逻辑 -->
5555

56-
差分数组
56+
**方法一:差分数组**
5757

5858
对于每个数,都有一个固定的 k 生效区间。我们先利用差分,预处理每个数的 k 生效区间。有最多个数能覆盖到的 k 即是答案。
5959

solution/1800-1899/1854.Maximum Population Year/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<!-- 这里可写通用的实现逻辑 -->
4444

45-
差分数组实现。
45+
**方法一:差分数组**
4646

4747
<!-- tabs:start -->
4848

solution/1900-1999/1943.Describe the Painting/README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
<!-- 这里可写通用的实现逻辑 -->
8282

83-
差分数组
83+
**方法一:差分数组**
8484

8585
<!-- tabs:start -->
8686

@@ -99,11 +99,7 @@ class Solution:
9999
n = len(s)
100100
for i in range(1, n):
101101
s[i][1] += s[i - 1][1]
102-
ans = []
103-
for i in range(n - 1):
104-
if s[i][1]:
105-
ans.append([s[i][0], s[i + 1][0], s[i][1]])
106-
return ans
102+
return [[s[i][0], s[i + 1][0], s[i][1]] for i in range(n - 1) if s[i][1]]
107103
```
108104

109105
### **Java**

solution/1900-1999/1943.Describe the Painting/README_EN.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ class Solution:
9292
n = len(s)
9393
for i in range(1, n):
9494
s[i][1] += s[i - 1][1]
95-
ans = []
96-
for i in range(n - 1):
97-
if s[i][1]:
98-
ans.append([s[i][0], s[i + 1][0], s[i][1]])
99-
return ans
95+
return [[s[i][0], s[i + 1][0], s[i][1]] for i in range(n - 1) if s[i][1]]
10096
```
10197

10298
### **Java**

solution/1900-1999/1943.Describe the Painting/Solution.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ def splitPainting(self, segments: List[List[int]]) -> List[List[int]]:
88
n = len(s)
99
for i in range(1, n):
1010
s[i][1] += s[i - 1][1]
11-
ans = []
12-
for i in range(n - 1):
13-
if s[i][1]:
14-
ans.append([s[i][0], s[i + 1][0], s[i][1]])
15-
return ans
11+
return [[s[i][0], s[i + 1][0], s[i][1]] for i in range(n - 1) if s[i][1]]

0 commit comments

Comments
 (0)