mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update bst_is_valid.py
This commit is contained in:
parent
5108f546c6
commit
faa7b70a00
@ -14,10 +14,8 @@ def is_valid_bst_iterative(root):
|
|||||||
if node:
|
if node:
|
||||||
if min_val >= node.val or node.val >= max_val:
|
if min_val >= node.val or node.val >= max_val:
|
||||||
return False
|
return False
|
||||||
if node.left:
|
queue.append((node.left, min_val, node.val))
|
||||||
queue.append((node.left, min_val, node.val))
|
queue.append((node.right, node.val, max_val))
|
||||||
if node.right:
|
|
||||||
queue.append((node.right, node.val, max_val))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user