`{"id":"494be2c1-8ede-483e-8e2c-eaeb18c5cfcb","name":"Maximum Number Of 1's Row","description":"Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":" 1 &lt;= n, m &lt;= 40\r\n0 &lt;= mat[][] &lt;= 1","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\n\nusing namespace std;\n\nint findRow(vector<vector<int>> &mat){\n // write your code here\n \n return 0;\n}\n\nint main() {\n int n , m;\n cin >> n;\n cin >> m;\n vector<vector<int>> mat(n, vector<int> (m));\n for(int i = 0; i < n; i++){\n for(int j = 0; j < m; j++){\n cin >> mat[i][j];\n }\n }\n \n cout << findRow(mat) << endl;\n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int findRow(int[][]mat) {\r\n //write your code here\r\n return -1;\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int m = scn.nextInt();\r\n\r\n int[][]mat = new int[n][m];\r\n\r\n for (int i = 0; i < n; i++) {\r\n for (int j = 0; j < m; j++) {\r\n mat[i][j] = scn.nextInt();\r\n }\r\n }\r\n\r\n System.out.println(findRow(mat));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4 3\r\n0 1 1\r\n0 0 1\r\n1 1 1\r\n0 0 1","sampleOutput":"2","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":"163131e4-0cee-4dd7-a2be-5342a9f4b4fc","name":"Maximum Number Of 1's Row","slug":"maximum-number-of-1-s-row","type":1}],"next":{"id":"802743a4-daf2-4c00-b840-593c22e796cb","name":"Maximum Number Of 1's Row","type":3,"slug":"maximum-number-of-1-s-row"},"prev":{"id":"7c69d429-0231-4db0-840a-8b7d8ad44598","name":"K-th Smallest Prime Fraction MCQ","type":0,"slug":"k-th-smallest-prime-fraction-mcq"}}}`

# Maximum Number Of 1's Row

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.

`{"id":"494be2c1-8ede-483e-8e2c-eaeb18c5cfcb","name":"Maximum Number Of 1's Row","description":"Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":" 1 &lt;= n, m &lt;= 40\r\n0 &lt;= mat[][] &lt;= 1","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\n\nusing namespace std;\n\nint findRow(vector<vector<int>> &mat){\n // write your code here\n \n return 0;\n}\n\nint main() {\n int n , m;\n cin >> n;\n cin >> m;\n vector<vector<int>> mat(n, vector<int> (m));\n for(int i = 0; i < n; i++){\n for(int j = 0; j < m; j++){\n cin >> mat[i][j];\n }\n }\n \n cout << findRow(mat) << endl;\n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int findRow(int[][]mat) {\r\n //write your code here\r\n return -1;\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int m = scn.nextInt();\r\n\r\n int[][]mat = new int[n][m];\r\n\r\n for (int i = 0; i < n; i++) {\r\n for (int j = 0; j < m; j++) {\r\n mat[i][j] = scn.nextInt();\r\n }\r\n }\r\n\r\n System.out.println(findRow(mat));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4 3\r\n0 1 1\r\n0 0 1\r\n1 1 1\r\n0 0 1","sampleOutput":"2","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":"163131e4-0cee-4dd7-a2be-5342a9f4b4fc","name":"Maximum Number Of 1's Row","slug":"maximum-number-of-1-s-row","type":1}],"next":{"id":"802743a4-daf2-4c00-b840-593c22e796cb","name":"Maximum Number Of 1's Row","type":3,"slug":"maximum-number-of-1-s-row"},"prev":{"id":"7c69d429-0231-4db0-840a-8b7d8ad44598","name":"K-th Smallest Prime Fraction MCQ","type":0,"slug":"k-th-smallest-prime-fraction-mcq"}}}`

Editor

# Maximum Number Of 1's Row

easy

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.

## Constraints

1 <= n, m <= 40 0 <= mat[][] <= 1

## Format

### Input

Input is managed for you

### Output

Output is managed for you

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}4 3 0 1 1 0 0 1 1 1 1 0 0 1```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}2`

Discussions

Show Discussion

Related Resources