{"id":"6e7bebfe-d084-439e-8d28-56d978472a7e","name":"Count Zeros In A Sorted Matrix","description":"Given a Binary Square Matrix where each row and column of the matrix is sorted in ascending order. Find the total number of Zeros present in the matrix.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you","constraints":"1 &lt;= T &lt;= 50\r\n1 &lt;= M,N &lt;= 1000\r\n0 &lt;= A[i][j] &lt;= 1","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int countZeros(int[][]mat) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[][]mat = new int[n][n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n for (int j = 0; j < n; j++) {\r\n mat[i][j] = scn.nextInt();\r\n }\r\n }\r\n\r\n System.out.println(countZeros(mat));\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3 \r\n0 0 1\r\n0 1 1\r\n0 1 1","sampleOutput":"4","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"8195eab8-2b90-47af-b4e7-a21bc19e28dd","name":"Count Zeros In A Sorted Matrix","slug":"count-zeros-in-a-sorted-matrix","type":1}],"next":{"id":"0efe35e6-5da2-4f77-831c-32b13597bd66","name":"Count Zeros In A Sorted Matrix","type":3,"slug":"count-zeros-in-a-sorted-matrix"},"prev":{"id":"f6b0e6f4-85e6-4e6b-bdce-97624fce0e8c","name":"Split Array Largest Sum MCQ","type":0,"slug":"split-array-largest-sum-mcq"}}}

Count Zeros In A Sorted Matrix

Given a Binary Square Matrix where each row and column of the matrix is sorted in ascending order. Find the total number of Zeros present in the matrix.

{"id":"6e7bebfe-d084-439e-8d28-56d978472a7e","name":"Count Zeros In A Sorted Matrix","description":"Given a Binary Square Matrix where each row and column of the matrix is sorted in ascending order. Find the total number of Zeros present in the matrix.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you","constraints":"1 &lt;= T &lt;= 50\r\n1 &lt;= M,N &lt;= 1000\r\n0 &lt;= A[i][j] &lt;= 1","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int countZeros(int[][]mat) {\r\n //write your code here\r\n return 0;\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[][]mat = new int[n][n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n for (int j = 0; j < n; j++) {\r\n mat[i][j] = scn.nextInt();\r\n }\r\n }\r\n\r\n System.out.println(countZeros(mat));\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3 \r\n0 0 1\r\n0 1 1\r\n0 1 1","sampleOutput":"4","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"8195eab8-2b90-47af-b4e7-a21bc19e28dd","name":"Count Zeros In A Sorted Matrix","slug":"count-zeros-in-a-sorted-matrix","type":1}],"next":{"id":"0efe35e6-5da2-4f77-831c-32b13597bd66","name":"Count Zeros In A Sorted Matrix","type":3,"slug":"count-zeros-in-a-sorted-matrix"},"prev":{"id":"f6b0e6f4-85e6-4e6b-bdce-97624fce0e8c","name":"Split Array Largest Sum MCQ","type":0,"slug":"split-array-largest-sum-mcq"}}}
plane

Editor


Loading...

Count Zeros In A Sorted Matrix

easy

Given a Binary Square Matrix where each row and column of the matrix is sorted in ascending order. Find the total number of Zeros present in the matrix.

Constraints

1 <= T <= 50 1 <= M,N <= 1000 0 <= A[i][j] <= 1

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

3 0 0 1 0 1 1 0 1 1

Sample Output

4

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode