Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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
Comment

PREVIOUS NEXT
Code Example
Java :: what is xml file in java 
Java :: sfadffocusbutton 
Java :: java no enum constant 
Java :: quick sort in java progrmmieren 
Java :: java file and stream 
Java :: java pattern matching 16 
Java :: light black border android 
Java :: with uses in python 
Java :: android dynamically create layer-list with item and shape site:stackoverflow.com 
Java :: Algorithms - count 
Java :: compile option in android 
Java :: Hibernate/JPA criteria query 
Java :: jdned 
Java :: what singleton java spring 
Java :: licenceurl 
Java :: android notification addaction example 
Java :: v2ray 
Java :: Java create an object of the static class Mammal 
Java :: Java @Repeatable 
Java :: print java object inherited classes 
Java :: ResultSet rs = ps.executeQuery() 
Java :: variables en java 
Java :: RTC_WAKEUP 
Java :: regex plit string with dash or undescore java 
Java :: for loop in firebase snapshot in java 
Java :: add SOSL to apex Example 
Java :: google pass api integration in java 
Java :: function compose method java 8 
Java :: imagebutton get background color programmatically 
Java :: Using UUID spring boot Neo4J 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =