Skip to content

Commit a55db73

Browse files
CaedenPHcclauss
andauthored
Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent 63c5147 commit a55db73

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

matrix/count_negative_numbers_in_sorted_matrix.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,10 @@ def count_negatives_brute_force_with_break(grid: list[list[int]]) -> int:
121121
3
122122
"""
123123
total = 0
124-
length_of_n = len(grid[0])
125-
for m in range(len(grid)):
126-
for index, n in enumerate(range(length_of_n)):
127-
if grid[m][n] < 0:
128-
total += length_of_n - index
124+
for row in grid:
125+
for i, number in enumerate(row):
126+
if number < 0:
127+
total += len(row) - i
129128
break
130129
return total
131130

0 commit comments

Comments
 (0)