The lowest common ancestor (LCA) of any two nodes p and q in a tree, or a directed acyclic graph, is the lowest/deepest node that is the ancestor of p and q (i.e. p and q are the descendants of this node). p and q are both ancestors/descendants of themselves.
hamza-mughees / lowest-common-ancestor-python Goto Github PK
View Code? Open in Web Editor NEWImplementation of the solution to the Lowest Common Ancestor problem with Python