(TreeNode t1, TreeNode t2)
| 8 | public class Question { |
| 9 | |
| 10 | public static boolean containsTree(TreeNode t1, TreeNode t2) { |
| 11 | if (t2 == null) |
| 12 | return true; // The empty tree is a subtree of every tree. |
| 13 | else |
| 14 | return subTree(t1, t2); |
| 15 | } |
| 16 | |
| 17 | /* Checks if the binary tree rooted at r1 contains the binary tree |
| 18 | * rooted at r2 as a subtree somewhere within it. |