Solution: Sort an Array
Explore how to implement a sorting algorithm that sorts an integer array in ascending order with guaranteed O(n log n) time and minimal extra space. Understand why heap sort is optimal for this task and learn the process of building a max heap and repeatedly re-heapifying to achieve an efficient in-place sort.
We'll cover the following...
We'll cover the following...
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
time and use the minimum possible extra space.
Constraints:
nums.lengthnums[i]...