-
Notifications
You must be signed in to change notification settings - Fork 2
/
88.py
50 lines (43 loc) · 1.17 KB
/
88.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# [ LeetCode ] 88. Merge Sorted Array
def solution(nums1: list[int], m: int, nums2: list[int], n: int) -> list[int]:
m, n = len(nums1) - len(nums2), len(nums2)
for i in range(n):
nums1[m+i], nums2[i] = nums2[i], nums1[m+i]
nums1.sort()
return nums1
def another_solution(
nums1: list[int], m: int, nums2: list[int], n: int
) -> list[int]:
pass
if __name__ == "__main__":
cases: list[dict[str, dict[str, list[int] | int] | list[int]]] = [
{
"input": {
"nums1": [1, 2, 3, 0, 0, 0],
"m": 3,
"nums2": [2, 5, 6],
"n": 3
},
"output": [1, 2, 2, 3, 5, 6]
},
{
"input": {
"nums1": [1],
"m": 1,
"nums2": [],
"n": 0
},
"output": [1]
},
{
"input": {
"nums1": [0],
"m": 0,
"nums2": [1],
"n": 1
},
"output": [1]
}
]
for case in cases:
assert case["output"] == solution(**case["input"])