Skip to content

Vishakha263/ArrayEasy4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

ArrayEasy4

https://practice.geeksforgeeks.org/problems/count-the-zeros2550/1/?category[]=Arrays&category[]=Arrays&problemStatus=unsolved&difficulty[]=0&page=1&query=category[]ArraysproblemStatusunsolveddifficulty[]0page1category[]Arrays#

Given an array of size N consisting of only 0's and 1's. The array is sorted in such a manner that all the 1's are placed first and then they are followed by all the 0's. Find the count of all the 0's.

Example 1:

Input: N = 12 Arr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0} Output: 3 Explanation: There are 3 0's in the given array.

Example 2:

Input: N = 5 Arr[] = {0, 0, 0, 0, 0} Output: 5 Explanation: There are 5 0's in the array.

Your Task: You don't need to read input or print anything. Your task is to complete the function countZeroes() which takes the array of integers arr[] and its size n as input parameters and returns the number of zeroes present in the array.

Expected Time Complexity: O(logN) Expected Auxiliary Space: O(1)

Constraints: 1 <= N <= 105 0 <= Arr[i] <= 1