思路:
将多余位置的数字删除,然后只需将nums2的数据从末端插入,然后进行排序即可
class Solution(object):
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: None Do not return anything, modify nums1 in-place instead.
"""
del nums1[m:]
for i in range(n):
nums1.append(nums2[i])
nums1.sort()