Skip to content

Commit 5c605df

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

data_structures/persistent_segment_tree.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from typing import List, Optional
22

3+
34
class Node:
45
def __init__(self, value: int = 0) -> None:
56
self.value: int = value
67
self.left: Optional[Node] = None
78
self.right: Optional[Node] = None
89

10+
911
class PersistentSegmentTree:
1012
def __init__(self, arr: List[int]) -> None:
1113
self.n: int = len(arr)
@@ -120,12 +122,15 @@ def _query(self, node: Node, start: int, end: int, left: int, right: int) -> int
120122
if left <= start and right >= end:
121123
return node.value
122124
mid = (start + end) // 2
123-
return (self._query(node.left, start, mid, left, right) +
124-
self._query(node.right, mid + 1, end, left, right))
125+
return self._query(node.left, start, mid, left, right) + self._query(
126+
node.right, mid + 1, end, left, right
127+
)
128+
125129

126130
# Running the doctests
127131
if __name__ == "__main__":
128132
import doctest
133+
129134
print("Running doctests...")
130135
result = doctest.testmod()
131136
print(f"Ran {result.attempted} tests, {result.failed} failed.")

0 commit comments

Comments
 (0)