Check Sub-Tree
T1 and T2 are two very large binary trees, with T1 much bigger than T2. Create an algorithm to determine if T2 is a subtree of T1.
A tree T2 is a subtree of T1 if there exists a node n in T1 such that the subtree of n is identical to T2. That is, if you cut off the tree at node n, the two trees would be identical.
Link here to the repo to solve the problem
👉👌 Tips
Hints: #4, #11, #18, #31, #37
XXX
XXX
XXX
👊 Solution 1
xxx
public boolean solution(String s1, String s2) {
return false;
}
👊 Solution 2
xxxx
public boolean solution(String s1, String s2) {
return false;
}
Question borrowed from “Cracking the coding interview”