Computer Science, asked by Sambhawna7817, 1 year ago

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

Answers

Answered by anna5560
0
  • given a sorted array consisting 0s and 1S the problem is to find the index of first first is the shortest way it could be possible that the array consists of only 0s for only one as if one has not present in the array then print -1 examples like input output the index 1 is not present in shorted array like that

like input array 0, 1, 0, 1, 0, 0, 1, 1 output array 0, 0, 0, 0, 0, 1, 1, 1 there are methods of 0s and 1S first count the number of 0s second once we have found

  1. methods of 0s and 1S first count the number of 0s second once we have count we can put any number 0s at the beginning and 1S at the remaining and remaining and n-c position in array
Similar questions