mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-15 10:17:35 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
eb9e2b73c6
commit
5c605df8b2
@ -1,11 +1,13 @@
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, value: int = 0) -> None:
|
||||
self.value: int = value
|
||||
self.left: Optional[Node] = None
|
||||
self.right: Optional[Node] = None
|
||||
|
||||
|
||||
class PersistentSegmentTree:
|
||||
def __init__(self, arr: List[int]) -> None:
|
||||
self.n: int = len(arr)
|
||||
@ -120,12 +122,15 @@ class PersistentSegmentTree:
|
||||
if left <= start and right >= end:
|
||||
return node.value
|
||||
mid = (start + end) // 2
|
||||
return (self._query(node.left, start, mid, left, right) +
|
||||
self._query(node.right, mid + 1, end, left, right))
|
||||
return self._query(node.left, start, mid, left, right) + self._query(
|
||||
node.right, mid + 1, end, left, right
|
||||
)
|
||||
|
||||
|
||||
# Running the doctests
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
|
||||
print("Running doctests...")
|
||||
result = doctest.testmod()
|
||||
print(f"Ran {result.attempted} tests, {result.failed} failed.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user