Leftmost Column with at Least a One
Problem Description
You are given a binary matrix with rows sorted in non-decreasing order.
Implement a function to return the index of the leftmost column with at least a 1 in it.
If no such column exists, return -1.
The matrix is only accessible via a BinaryMatrix interface with the following methods:
- get(row, col): returns the value at that cell (0 or 1)
- dimensions(): returns [rows, cols]
Example Test Cases
Example 1
Input: [[[0,0,0,1],[0,0,1,1],[0,0,0,0]]]
Expected: 2
Example 2
Input: [[[0,0],[1,1]]]
Expected: 0
Run your code to see the results