Convert Min Heap to Max Heap Problem Statement
Given an array representation of a min-heap of size 'n', your task is to convert this array into a max-heap.
Input:
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next 2*T lines represent test cases.
The first line contains a single integer ‘n’ denoting the size of the array.
The next line contains ‘n’ space-separated integers denoting the min-heap.
Output:
Return any possible max-heap for the given input min-heap.
Output for each query is printed in a separate line.
Example:
Input:
min-heap = [1,2,3,6,7,8]
Output:
max-heap = [8,7,3,6,2,1]
Constraints:
- 1 <= T <= 10
- 1 <= n <= 5000
- 1 <= arr[i] <= 105
- Time Limit: 1 sec
Note:
The output max-heap will be checked from the given function: if the output array is a max-heap, it will return true; otherwise, it will return false.
Be the first one to answer
Add answer anonymously...
Top UBS Business Technology Analyst interview questions & answers
Popular interview questions of Business Technology Analyst
Top HR questions asked in UBS Business Technology Analyst
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app