Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5982173

Browse files
committed
feat: update solutions to lc problems
1 parent f44ad30 commit 5982173

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

‎solution/0000-0099/0088.Merge Sorted Array/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ class Solution:
8787
k -= 1
8888
```
8989

90+
```python
91+
class Solution:
92+
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
93+
"""
94+
Do not return anything, modify nums1 in-place instead.
95+
"""
96+
i, j, k = m - 1, n - 1, m + n - 1
97+
while j >= 0:
98+
if i < 0 or nums1[i] < nums2[j]:
99+
nums1[k] = nums2[j]
100+
j -= 1
101+
else:
102+
nums1[k] = nums1[i]
103+
i -= 1
104+
k -= 1
105+
```
106+
90107
### **Java**
91108

92109
<!-- 这里可写当前语言的特殊实现逻辑 -->

‎solution/0000-0099/0088.Merge Sorted Array/README_EN.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ class Solution:
7676
k -= 1
7777
```
7878

79+
```python
80+
class Solution:
81+
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
82+
"""
83+
Do not return anything, modify nums1 in-place instead.
84+
"""
85+
i, j, k = m - 1, n - 1, m + n - 1
86+
while j >= 0:
87+
if i < 0 or nums1[i] < nums2[j]:
88+
nums1[k] = nums2[j]
89+
j -= 1
90+
else:
91+
nums1[k] = nums1[i]
92+
i -= 1
93+
k -= 1
94+
```
95+
7996
### **Java**
8097

8198
```java

‎solution/0200-0299/0240.Search a 2D Matrix II/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
由于每一行升序排列,因此可以对每一行执行二分查找。
5353

54-
时间复杂度 O(mlogn)。
54+
时间复杂度 $O(mlogn)$
5555

5656
**方法二:从左下角或右上角搜索**
5757

@@ -63,7 +63,7 @@
6363

6464
若搜索结束依然找不到 target,返回 false。
6565

66-
时间复杂度 O(m + n)
66+
时间复杂度 $O(m+n)$
6767

6868
<!-- tabs:start -->
6969

‎solution/2300-2399/2312.Selling Pieces of Wood/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
设 $dp[i][j]$ 表示对一块高为 $i,ドル宽为 $j$ 的木块切割后能得到的最多钱数。答案就是 $dp[m][n]$。
7878

79-
时间复杂度 $O(m*n*(m+n))$。
79+
时间复杂度 $O(mn(m+n))$。
8080

8181
<!-- tabs:start -->
8282

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /