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

Method commonAncestor

java/Chapter 4/Question4_7/QuestionB.java:25–30  ·  view source on GitHub ↗
(TreeNode root, TreeNode p, TreeNode q)

Source from the content-addressed store, hash-verified

23 }
24
25 public static TreeNode commonAncestor(TreeNode root, TreeNode p, TreeNode q) {
26 if (!covers(root, p) || !covers(root, q)) { // Error check - one node is not in tree
27 return null;
28 }
29 return commonAncestorHelper(root, p, q);
30 }
31
32 public static void main(String[] args) {
33 int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

Callers 1

mainMethod · 0.95

Calls 2

coversMethod · 0.95
commonAncestorHelperMethod · 0.95

Tested by

no test coverage detected