Skip to content

Commit 60e1a07

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2750717 commit 60e1a07

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Diff for: data_structures/arrays/sparse_table.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def build_sparse_table(number_list: list[int]) -> list[list[int]]:
1616
"""
1717
Precompute range minimum queries with power of two length and store the precomputed
1818
values in a table.
19-
19+
2020
>>> build_sparse_table([8, 1, 0, 3, 4, 9, 3])
2121
[[8, 1, 0, 3, 4, 9, 3], [1, 0, 0, 3, 4, 3, 0], [0, 0, 0, 3, 0, 0, 0]]
2222
>>> build_sparse_table([3, 1, 9])
@@ -56,10 +56,9 @@ def build_sparse_table(number_list: list[int]) -> list[list[int]]:
5656
while (i + (1 << j) - 1) < length:
5757
# split range [i, i + 2 ** j] and find minimum of 2 halves
5858
sparse_table[j][i] = min(
59-
sparse_table[j - 1][i + (1 << (j - 1))],
60-
sparse_table[j - 1][i]
59+
sparse_table[j - 1][i + (1 << (j - 1))], sparse_table[j - 1][i]
6160
)
62-
61+
6362
i += 1
6463

6564
j += 1
@@ -100,10 +99,7 @@ def query(sparse_table: list[list[int]], left_bound: int, right_bound: int) -> i
10099
minimum of 2 overlapping smaller subsets: [left_bound, left_bound + 2 ** j - 1]
101100
and [right_bound - 2 ** j + 1, right_bound]
102101
"""
103-
return min(
104-
sparse_table[j][right_bound - (1 << j) + 1],
105-
sparse_table[j][left_bound]
106-
)
102+
return min(sparse_table[j][right_bound - (1 << j) + 1], sparse_table[j][left_bound])
107103

108104

109105
if __name__ == "__main__":

0 commit comments

Comments
 (0)