Loading problem…
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 as subRoot.
root
subRoot
true
A subtree includes a node and all of its descendants.
// root: // 3 // / \ // 4 5 // / \ // 1 2 // // subRoot: // 4 // / \ // 1 2 isSubtree([3,4,5,1,2], [4,1,2]); // true // root: // 3 // / \ // 4 5 // / \ // 1 2 // / // 0 // // subRoot: // 4 // / \ // 1 2 isSubtree([3,4,5,1,2,null,null,null,null,0], [4,1,2]); // false
3 hints available with Pro