0

input is

[1,2,3,0,0,0]
3
[2,5,6]
3

Code is

def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
    nums1 = nums1[0:m] + nums2[0:n]
    nums1.sort()
    print(nums1)

stdout is

[1, 2, 2, 3, 5, 6]

But, array is

[1,2,3,0,0,0]

Why is this the case?

I thought the array would be [1, 2, 2, 3, 5, 6] as well

azro
  • 53,056
  • 7
  • 34
  • 70
Bob
  • 21
  • 3
  • 1
    Please share how you call the code with the input you show. Reassining to `num1` doesn't change the value in the given array outside – azro Dec 18 '22 at 08:59

0 Answers0