[LeetCode] 88. Merge Sorted Array

开刷Top Interview 150

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.
        """
        #m=0
        if m == 0:
            nums1[:] = nums2
        #else
        nums1[:]=nums1[:m]+nums2
        nums1.sort()

image

posted @ 2024-06-30 11:08  夜歌乘年少  阅读(2)  评论(0编辑  收藏  举报