题目截图
方法一:直接合并然后排序
利用python的切片让数组nums1的从m到m+n个 位置赋值为数组nums2的元素,然后对nums1的元素排序。
复杂度
时间复杂度:
空间复杂度:
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
"""
nums1[m:m+n] = nu