Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

merge two sorted arrays python

def merge_two_sorted_arrays(nums1, nums2)
  while m > 0 and n > 0 : 
    if nums1[m-1] >= nums2[n-1]:
      nums1[n+m-1] = nums1[m-1]
      m = m - 1 
      else:
        nums1[n+m-1] = nums2[n-1]
        n = n - 1 
        if n > 0 :
          nums1[0:n] = nums2[:n]

          return 
 
PREVIOUS NEXT
Tagged: #merge #sorted #arrays #python
ADD COMMENT
Topic
Name
1+3 =