Блог пользователя BinaryCrazy

Автор BinaryCrazy, история, 5 лет назад, По-английски

Hi all,

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.


Logic

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.

Implementation.


Thanks a lot for your time and help.

It is greatly appreciated.

Regards,

BC

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится