Plz correct the code

Hello @rakesh800650,

Mistakes:

  1. Read the constraints properly:
    0 <= xi <= 1,000,000,000
    You are using data type as int which will give wrong output for above range.

  2. you have initialized e with wrong value.

  3. you have right shifted the wrong number of times which is leading to division by 4 instead of 2.

  4. You need a sorted array for binary search.

Corrected code:

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.