mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-30 04:36:08 -04:00
Update lowest_common_ancestor.py
This commit is contained in:
parent
d5089d5b0e
commit
35b14ddfde
@ -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.
|
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 lowest_common_ancestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
|
||||||
|
|
||||||
def dfs(root, p, q):
|
def dfs(root, p, q):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user