menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Find the i...
source image

Prodevelopertutorial

1w

read

228

img
dot

Find the index of first 1 in an infinite sorted array of 0s and 1s

  • The problem is to find the index of the first occurrence of 1 in an infinite sorted array of 0s and 1s.
  • To solve this, we can apply binary search. However, to apply binary search, we need to know the start and end indices of the array.
  • To find the end index, we start with index 1 and keep doubling it until we find a 1.
  • Once we have the start and end indices, we perform binary search to find the first occurrence of 1.

Read Full Article

like

13 Likes

For uninterrupted reading, download the app