311. Row with Most Ones
EasyBinary Search
Each row of the binary matrix is sorted (0s then 1s). Print the 0-based index of the first row with the most 1s, or -1 if there are no 1s.
Input format
Line 1: r c Next r lines: c values
Output format
The row index, or -1.
Example 1
Input
4 4 0 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0
Output
2
Example 2
Input
2 2 0 0 0 0
Output
-1
Constraints
1 ≤ r, c ≤ 1000
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…