educative.io

Sorted Array with duplicates

array says X which is sorted and has duplicates. How best can you find an index say i such that element at that index is also i . That is X[i] = i .

Its a famous question when duplicaes are not present

When duplicates are present for say
-100,0,1,3,3,3,3,3,3
here it becomes difficult to do binary search on ( X[i] - i ==0 )

Hi Manish,

Thank you for reaching out to us! Can you specify which part in the challenge we can help you with?

Best Regards,

Team Educative