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

Method covers

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

Source from the content-addressed store, hash-verified

4
5public class QuestionB {
6 public static boolean covers(TreeNode root, TreeNode p) {
7 if (root == null) return false;
8 if (root == p) return true;
9 return covers(root.left, p) || covers(root.right, p);
10 }
11
12 public static TreeNode commonAncestorHelper(TreeNode root, TreeNode p, TreeNode q) {
13 if (root == null) {

Callers 2

commonAncestorHelperMethod · 0.95
commonAncestorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected