88. Merge Sorted Array

Updated: 2024-03-12
1 min read
[Array Two Pointers Sorting]

On This Page

LeetCode problem

First accepted

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.
        """
        i = len(nums1) - n
        for j in nums2:
            nums1[i] = j
            i += 1
        nums1.sort()