(TreeNode root, TreeNode p)
| 4 | |
| 5 | public 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) { |
no outgoing calls
no test coverage detected