Back to problems

Leftmost Column with At Least a One

Algorithm · Uber · Medium

This practice variant provides the binary matrix directly through binaryMatrix. Every row is sorted in non-decreasing order. Your task is to return the index of the first column that contains at least one 1. If the matrix contains no 1, return -1. Examples Example 1: Input: binaryMatrix = [[0,0],[1,1]] Output: 0 The first column already contains a 1, so its index is 0. Example 2: Input: binaryMatrix = [[0,0],[0,0]] Output: -1 Because every entry is 0, there is no qualifying…

Checking your access…