Horje
number of zeros in a binary array Code Example
number of zeros in a binary array
class Solution:
    def countZeroes(self, arr, N):
        start = 0
        end = N-1;
        
        if (arr[0] == 0): return N
        if (arr[0] == 1 and arr[1] == 0): return N-1
        if (arr[N-1] == 1): return 0
        
        while (start <= end):
            mid = start + (end-start)//2
            if (arr[mid] == 0 and arr[mid-1] == 1): return N-mid
            if (arr[mid] == 1 and arr[mid+1] == 0): return N-(mid+1)
            
            if (arr[mid] == 1 and arr[mid+1] == 1): start = mid+1
            else: end = mid-1
        return N




Java

Related
why to use serializable with java bean Code Example why to use serializable with java bean Code Example
split string to textview in android Code Example split string to textview in android Code Example
como detener un void java Code Example como detener un void java Code Example
java optional parameters Code Example java optional parameters Code Example
when we say x language is object oriented programming language what do we mean by that Code Example when we say x language is object oriented programming language what do we mean by that Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8