From ea7cdd0b979ac717f22db0a90bc530b5b9d7fd15 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Sun, 10 Nov 2019 23:39:20 +0530 Subject: [PATCH] Fixed bug in get depth of Problem 9.4 for python #110 --- .../lowest_common_ancestor_with_parent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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