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

Method commonAncestor

java/Chapter 4/Question4_7/QuestionC.java:46–52  ·  view source on GitHub ↗
(TreeNode root, TreeNode p, TreeNode q)

Source from the content-addressed store, hash-verified

44 }
45
46 public static TreeNode commonAncestor(TreeNode root, TreeNode p, TreeNode q) {
47 Result r = commonAncestorHelper(root, p, q);
48 if (r.isAncestor) {
49 return r.node;
50 }
51 return null;
52 }
53
54 public static void main(String[] args) {
55 int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

Callers 1

mainMethod · 0.95

Calls 1

commonAncestorHelperMethod · 0.95

Tested by

no test coverage detected