From f8dc224ae5ef1aed4348328eb7657add204f8b1c Mon Sep 17 00:00:00 2001 From: bt3gl <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:00:29 -0700 Subject: [PATCH] Update bst_lowest_common_ancestor.py --- trees/bst_lowest_common_ancestor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trees/bst_lowest_common_ancestor.py b/trees/bst_lowest_common_ancestor.py index 1217b8a..db1a945 100644 --- a/trees/bst_lowest_common_ancestor.py +++ b/trees/bst_lowest_common_ancestor.py @@ -2,14 +2,14 @@ # -*- coding: utf-8 -*- # author: bt3gl - def lca(self, root, p, q): - - node = root - this_lcw = root.val + +def lowest_common_ancestor(root, p, q): + + node, result = root, root while node: - this_lcw = node + result = node if node.val > p.val and node.val > q.val: node = node.left @@ -20,4 +20,4 @@ else: break - return this_lcw + return result