Leftmost One
Example
Explanation:
Arr[1][0] is the leftmost 1 in all rows and its column is 0.Explanation:
Arr[1][1] is the leftmost 1 in all rows and its column is 1.Notice
Last updated
Explanation:
Arr[1][0] is the leftmost 1 in all rows and its column is 0.Explanation:
Arr[1][1] is the leftmost 1 in all rows and its column is 1.Last updated
class Solution:
"""
@param arr: The 2-dimension array
@return: Return the column the leftmost one is located
"""
def getColumn(self, arr):
# Write your code here
if not arr or not arr[0]:
return -1
n = len(arr)
m = len(arr[0])
idx = m-1
for row in arr:
while idx >=0:
if row[idx] == 0:
break
idx -=1
return idx+1