Back to course home
0% completed
Vote For New Content
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
tcan be found as a subtree ofsrooted 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!