If the first element in the array is largest then the output is wrong.
9
4 2 3 3 5 4 5 4 5
3
Considering this as input, if we just solve for first k elements then the output comes as:
4 4 4 4 3 (output for first k elements)
It should have been 4 3…i dont know why these extra 4s are there.Please explain this test case