Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. class Solution:
  2.     def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
  3.         """
  4.        Do not return anything, modify nums1 in-place instead.
  5.        """
  6.         while m > 0 and n > 0:
  7.             if nums1[m-1] >= nums2[n-1]:
  8.                 nums1[m+n-1] = nums1[m-1]
  9.                 m -= 1
  10.             else:
  11.                 nums1[m+n-1] = nums2[n-1]
  12.                 n -= 1
  13.         if n > 0:
  14.             nums1[:n] = nums2[:n]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement