
Suppose given ‘HEIGHT_ARR’ is { 4, 2, 3, 1 } so we return { 0, 2, 3 } as ‘0th’ index building is ‘4’ which is greater than all other buildings on the right side. ‘1st’ index has ‘2’ which is smaller than ‘3’ so we don’t include it (hidden by building height with ‘3’). We include ‘3’ as it is greater than ‘1’ then we consider ‘1’ as nothing is on the right side of ‘1’.
The first line of input contains a ‘T’ number of test cases.
The first line of each test case contains an integer ‘N’ i.e size of the array ‘HEIGHT_ARR’.
The second line of each test case contains an array ‘HEIGHT_ARR’, where ‘HEIGHT_ARR[i]’ denotes the height of the ‘ith’ building.
For each test case, return an array containing the index of those building which have a smaller building in the right side of them.
You are not required to print anything explicitly. It has already been taken care of. Just implement the function.
1 <= T <= 100
1 <= N <= 1000
1 <= HEIGHT_ARR[i] <= 10^5
Where ‘T’ represents the number of test cases and ‘N’ represents the size of the array and ‘HEIGHT_ARR[i]’ represents the elements of the array.
Time Limit: 1 second
The idea here is to traverse the array starting from the ‘0th’ index and look for the given condition.
The idea here is to traverse the array from last and maintain a maximum and if the element is greater than the maximum we choose that element.