The problem. Sort an array of integers nums in ascending order, in place, in O(n log n) time — using a heap.
nums = [5, 2, 9, 1, 6, 3] -> [1, 2, 3, 5, 6, 9]
nums = [3, 3, 1] -> [1, 3, 3]
nums = [-2, 0, -5] -> [-5, -2, 0]Members only · free account
The rest of this lesson, with 7 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson