[LeetCode]#88. Merge Sorted Array

Input:
nums1 = [1,2,3,0,0,0], m = 3
nums2 = [2,5,6], n = 3
Output: [1,2,2,3,5,6]
class Solution(object):
def merge(self, nums1, m, nums2, n):
nums1[m:] = nums2[:]
for i in range(len(nums1)-1):
for j in range(len(nums1)-i-1):
if nums1[j]>nums1[j+1]:
nums1[j],nums1[j+1] = nums1[j+1],nums1[j]
return nums1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store