
Consider the row : [ 3, 1, 5, 12, 10], with 1-based indexing -
For index 3, there would be 2 supporters, index 1 and index 2, but index 2 is closest, hence for index 3, we will store ‘1’ (Rating of contestant).
For index 5, we will store ‘5’(at index 3).
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’, which represents the size of the row.
The second line for each test case ‘N’ space-separated integers denoting the corresponding elements of the row.
For each test case, you need to print space-separated integers denoting the rating of the closest supporter on the left.
Print the output of each test case in a separated line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10000
-10^9 <= data <= 10^9
Where ‘data’ represents the given row elements.
Time limit: 1 sec
For each contestant, check all the players on the left side until one with a rating less than its rating is found.
What we can observe is that, if we encounter a value, then we can remove all the values which are processed and are greater than this value, as in the future they can’t be the answer for any contestant(as we already have a smaller rating which is near).
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers