Timer is Running

Given a matrix(2D array) M of size N*N consisting of 0s and 1s only. The task is to find the column with maximum number of 0s.

Example 1:

Input:
3
1 1 0
1 1 0
1 1 0

Output:
2

Explanation:
2nd column (0-based indexing) is having 3 zeros which is maximum.

Example 2:

Input:
3
0 1 0
0 0 1
0 1 0

Output:
0

Explanation:
0th column (0-based indexing) is having 3 zeros which is maximum.

Constraints:
1 <= N <= 102
0 <= A[i][j] <= 1

User Task:
Your task is to complete the function columnWithMaxZero() which should return the column number with maximum number of zeros. If more than one column exists, print the one which comes first.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.