Search⌘ K
AI Features

Solution: Sort an Array

Solution: Sort an Array asks you to return an integer array in ascending order, including negative values, while implementing the sort yourself within the required time and space limits.

Statement

Given an integer array, nums, sort it in ascending order and return the sorted array.

You must implement the sorting algorithm yourself; do not use any built-in sorting functions. The solution must run in O(nlog⁡n)O(n \log n) time and use the minimum possible extra space.

Constraints:

  • 1≤1 \leq nums.length ...