Every row of matrix contains only 0 and 1, and each row is sorted: all its 0s come before all its 1s. Return the index of the row with the most 1s. If several rows tie, return the smallest index. If there is no 1 anywhere, return -1.
Example 1
Input:
row_with_most_ones([[0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 0, 1]])
Output:
1
Row 1 has three 1s.
Example 2
Input:
row_with_most_ones([[0, 0], [0, 0]])
Output:
-1
There is no 1.
0 <= rows, cols, and rows * cols <= 2 * 10**5No results yet
Run your code to check it against the examples, or submit to run every test.