Skip to content

Commit e9d86f1

Browse files
authored
Fix erase logic in treap.py
Adjust split logic to include the value in the right subtree.
1 parent 78817c4 commit e9d86f1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

data_structures/binary_tree/treap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def erase(root: Node | None, value: int) -> Node | None:
101101
Split all nodes with values greater into right.
102102
Merge left, right
103103
"""
104-
left, right = split(root, value - 1)
105-
_, right = split(right, value)
104+
left, right = split(root, value)
105+
_, right = split(right, value + 1)
106106
return merge(left, right)
107107

108108

0 commit comments

Comments
 (0)