Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.
30:00
Java
Subtree of Another Tree
easy
Topics
Companies
Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.
Example 1:
Input: {"root":[3,4,5,1,2],"subRoot":[4,1,2]}
Output: true
Constraints:
The number of nodes in root is in the range [1,2000].
The number of nodes in subRoot is in the range [1,1000].