Your question is Find Row With Minimum Ones. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The Navi app represents a binary status matrix where each row is sorted in nondecreasing order, so every 0 appears before every 1. Find the index of the row containing the minimum number of 1s.
If multiple rows contain the same minimum number of 1s, return the smallest row index.
Implement find_row_with_min_ones(matrix), where matrix is a non-empty rectangular list of lists containing only 0 and 1. Return an integer representing the zero-based index of the qualifying row.
Use the sorted order of each row to avoid counting every element individually.
def find_row_with_min_ones(matrix):