Hope you are having a great day. I found this question on HackerEarth, and received a "Partially Accepted" verdict, but have no idea why.
Can someone please explain where my logic is wrong? I have listed my logic below.
Sort all the values for which one needs to perform the HIT operations.
Next, for each value, binary search to find the last index that satisfies the following inequality:
a[i] — i >= x[i] (1 indexing)
We subtract that from the original value, and output the resulting array.
Thanks a lot for your time and help.
It is greatly appreciated.