@shawngao Nice work, buddy! I am with the same idea with @shuhua ( does not need to check if (s.val == t.val) in the first line of isSubtree at first, but it is very interesting that the Java version without the check line cannot pass with the error " java.lang.NullPointerException" pointed to the line return isSubtree(s.left, t) || isSubtree(s.right, t) . However the C++ version @shuhua provided can pass. Wierd, I don't why, is it because if s.left (or s.right) is null then s.left (or s.right) cannot be passed as parameters? Hope anybody can explain, great thanks!
Subtree of Another Tree