From 35b14ddfdebd6039c965725c5e2a9d8a77ac09af Mon Sep 17 00:00:00 2001 From: bt3gl <138340846+bt3gl-google@users.noreply.github.com> Date: Sun, 30 Jul 2023 15:52:52 -0700 Subject: [PATCH] Update lowest_common_ancestor.py --- trees_and_graphs/lowest_common_ancestor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trees_and_graphs/lowest_common_ancestor.py b/trees_and_graphs/lowest_common_ancestor.py index e4082ec..eebb9f6 100644 --- a/trees_and_graphs/lowest_common_ancestor.py +++ b/trees_and_graphs/lowest_common_ancestor.py @@ -1,8 +1,12 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# author: bt3gl + ''' Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. ''' -class ThisTree: +class Tree: def lowest_common_ancestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': def dfs(root, p, q):