MCPcopy Create free account
hub / github.com/careercup/ctci / commonAncestor

Function commonAncestor

python/Chapter 4/Question4_7/BinaryTreeNode.py:83–87  ·  view source on GitHub ↗
(root, p, q)

Source from the content-addressed store, hash-verified

81 return commonAncestorHelper(root.right, p, q)
82
83def commonAncestor(root, p, q):
84 if (not covers(root, p)) or (not covers(root, q)):
85 return None
86 else:
87 return commonAncestorHelper(root, p, q)
88# test
89bst2 = BinarySearchTree()
90n1 = TreeNode(0)

Callers 1

BinaryTreeNode.pyFile · 0.85

Calls 2

coversFunction · 0.85
commonAncestorHelperFunction · 0.85

Tested by

no test coverage detected