Skip to content

Commit 8ea6c0f

Browse files
committed
fixed type annotation
1 parent 6f62279 commit 8ea6c0f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

data_structures/binary_tree/segment_tree_node.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import Optional
2-
31
class Node:
42
def __init__(self, start: int, end: int) -> None:
53
# Initializes a segment tree node with start and end indices
64
self.start = start
75
self.end = end
8-
self.value: Optional[int] = None
9-
self.left: Optional["Node"] = None
10-
self.right: Optional["Node"] = None
6+
self.value: int | None = None
7+
self.left: Node | None = None
8+
self.right: Node | None = None
119

1210
class SegmentTree:
1311
def __init__(self, nums: list[int], mode: str = "max") -> None:
@@ -22,9 +20,9 @@ def __init__(self, nums: list[int], mode: str = "max") -> None:
2220
self.mode = "max" # Default to max if invalid mode is given
2321

2422
# Build the tree from the input list
25-
self.root: Optional[Node] = self.build(0, self.size - 1, nums)
23+
self.root: Node | None = self.build(0, self.size - 1, nums)
2624

27-
def build(self, start: int, end: int, nums: list[int]) -> Optional[Node]:
25+
def build(self, start: int, end: int, nums: list[int]) -> Node| None:
2826
"""
2927
Recursively builds the segment tree.
3028
:param start: Start index of the segment.

0 commit comments

Comments
 (0)