Convert Min Heap to Max Heap

Learning DSA practice problem on Onlearn.

Difficulty: medium.

Topics: How do you convert a min Heap to a max Heap?, Heap, Priority Queue, min-heap, heap, heap operations, heap representation, max-heap, tree traversal.

Heap Conversion Given a min heap represented as an array, convert it into a max heap without using any additional space. The conversion must be performed in place. Input: The first line contains an integer N (1 ≤ N ≤ 10^5), the size of the heap. The second line contains N space separated integers representing the min heap. Output: Print the N space separated integers representing the converted max heap. Example: Input: 5 1 2 3 4 5 Output: 5 4 3 2 1 Explanation: The given min heap [1, 2, 3, 4, 5] is converted to max heap [5, 4, 3, 2, 1] which satisfies the max heap property where each parent is greater than its children.