Sort an Array
Write merge sort: sort each half, then merge the two sorted halves.
The problem
Implement Solution.sortArray(nums) and return the numbers in ascending order. Write merge sort yourself: do not call sorted(), list.sort() or nums.sort(). For example, [5, 2, 3, 1] returns [1, 2, 3, 5]. 1 <= len(nums) <= 50000 and -50000 <= nums[i] <= 50000.
Starter code
class Solution:
def sortArray(self, nums):
passPublic examples
nums = [5, 2, 3, 1]gives[1, 2, 3, 5]nums = [9]gives[9]nums = [-3, 0, 4]gives[-3, 0, 4]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
