Back to course home
0% completed
Subtree of Another Tree (easy)
Problem Statement
Given two binary trees s
and t
, determine if tree t
is a subtree of tree s
. A tree t
is considered a subtree of s
if there exists a node in s
such that the subtree of that node is identical to t
. Both trees are considered identical if their structure and nodes are the same.
Examples

 Input:
 Tree
s
: [3,4,5,1,2]  Tree
t
: [4,1,2]
 Tree
 Expected Output: true
 Justification: Tree
t
can be found as a subtree ofs
rooted at the node with value 4.
 Input:

 Input:
 Tree
s
: [1,2,3]  Tree `t
 Tree
 Input:
.....
.....
.....
Like the course? Get enrolled and start learning!