← 返回 uber 的题目列表Leftmost Column with At Least a One
类型:qbank
Given a binary matrix where every row is sorted in non-decreasing order, return the index of the leftmost column that contains at least one 1, or -1 if no such column exists.
Leftmost Column with At Least a One
Given a binary matrix where every row is sorted in non-decreasing order, return the index of the leftmost column that contains at least one 1, or -1 if no such column exists.
SWE
grid
binary-search
two-pointer
medium
Frequency
Single report
Last asked
2026-06-04
Stage
phone-screen
Leftmost Column with At Least a One
You are given a binary matrix binaryMatrix, where every row is sorted in non-decreasing order.
Return the index of the leftmost column containing at least one 1, or -1 if no such column exists.
Examples
Example 1:
Input: binaryMatrix = [[0,0],[1,1]]
Output: 0
Example 2:
Input: binaryMatrix = [[0,0],[0,0]]
Output: -1
Constraints
1 <= binaryMatrix.length, binaryMatrix[i].length <= 100
Each row is sorted in non-decreasing order.