Skip to content

Commit f0a785c

Browse files
committed
chore: Fix pre-commit
1 parent 83d877c commit f0a785c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

matrix/count_negative_numbers_in_sorted_matrix.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def find_negative_index(array: list[int]):
6060
def count_negatives_binary_search(grid: list[list[int]]) -> int:
6161
"""
6262
An O(m logn) solution that uses binary search
63-
in order to find the boundary betweem positive and
63+
in order to find the boundary between positive and
6464
negative numbers
6565
6666
>>> count_negatives_binary_search(
@@ -107,7 +107,7 @@ def count_negatives_brute_force(grid: list[list[int]]) -> int:
107107

108108
def count_negatives_brute_force_with_break(grid: list[list[int]]) -> int:
109109
"""
110-
Similiar to the solution above, however uses break
110+
Similar to the solution above, however uses break
111111
in order to reduce the number of iterations
112112
113113
>>> count_negatives_brute_force_with_break(
@@ -133,7 +133,7 @@ def count_negatives_brute_force_with_break(grid: list[list[int]]) -> int:
133133
def generate_large_matrix() -> list[list[int]]:
134134
"""
135135
>>> generate_large_matrix() # doctest: +ELLIPSIS
136-
[[500, ..., -499], [499, ..., -501], ..., [2, ..., -998]]
136+
[[1000, ..., -999], [999, ..., -1001], ..., [2, ..., -1998]]
137137
"""
138138
return [list(range(1000 - i, -1000 - i, -1)) for i in range(1000)]
139139

@@ -144,17 +144,19 @@ def benchmark() -> None:
144144

145145
print("Running benchmarks")
146146
setup = (
147-
"from __main__ import count_negatives_binary_search, count_negatives_brute_force, "
148-
"count_negatives_brute_force_with_break, generate_large_matrix"
147+
"from __main__ import count_negatives_binary_search,count_negatives_brute_force"
148+
",count_negatives_brute_force_with_break,generate_large_matrix"
149149
)
150150

151-
cnbs = timeit(
151+
print(
152+
"count_negatives_binary_search()",
153+
timeit(
152154
"count_negatives_binary_search(generate_large_matrix())",
153155
setup=setup,
154156
number=5000,
155157
),
156-
157-
print("count_negatives_binary_search()", cnbs[0], "seconds")
158+
"seconds",
159+
)
158160
print(
159161
"count_negatives_brute_force_with_break()",
160162
timeit(
@@ -163,7 +165,7 @@ def benchmark() -> None:
163165
number=5000,
164166
),
165167
"seconds",
166-
) #
168+
)
167169
print(
168170
"count_negatives_brute_force()",
169171
timeit(

0 commit comments

Comments
 (0)