diff --git a/epi_judge_python_solutions/lowest_common_ancestor_with_parent.py b/epi_judge_python_solutions/lowest_common_ancestor_with_parent.py index c7eae6b37..62270ede2 100644 --- a/epi_judge_python_solutions/lowest_common_ancestor_with_parent.py +++ b/epi_judge_python_solutions/lowest_common_ancestor_with_parent.py @@ -12,7 +12,7 @@ def lca(node0: BinaryTreeNode, node1: BinaryTreeNode) -> Optional[BinaryTreeNode]: def get_depth(node): depth = 0 - while node: + while node.parent: depth += 1 node = node.parent return depth