← 返回 amazon 的题目列表Count zeros in sorted binary array using binary search
类型:online_judge
amazon
Given a sorted array consisting of 0s and 1s, design an efficient algorithm to find the number of 0s. Assume the array length is n, and the time complexity requirement is O(log n).
Input: A sorted array of 0s and 1s with a length not exceeding 10^6.
Output: An integer representing the number of 0s in the array.
Example: Input: [0, 0, 0, 1, 1] Output: 3
Example
Input
[0, 0, 0, 1, 1]