29. Sort an Array

Sort nums in ascending order without built-in sort functions, in O(n log n) time. (Implement merge sort, heap sort or a randomised quick sort.)

Example 1

Input: nums = [5,2,3,1]
Output: [1,2,3,5]

Example 2

Input: nums = [5,1,1,2,0,0]
Output: [0,0,1,1,2,5]
Hint 1

Split in half, sort each half recursively, then merge two sorted lists in linear time.

SortingDivide and Conquer