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. A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself.
Example 1
Input: root = [3,4,5,1,2], subRoot = [4,1,2]
Output: true
Explanation: The root's left child is 4, with children 1 and 2, exactly matching subRoot.
Example 2
Input: root = [3,4,5,1,2,null,null,null,null,0], subRoot = [4,1,2]
Output: false
Explanation: Node 4 has children 1 and 2, but 2 also has a child 0 that subRoot lacks. A subtree must include all descendants, so it is not a match.
Example 3
Input: root = [1,1], subRoot = [1]
Output: true
Explanation: The leaf node 1 at the bottom is a one-node subtree identical to subRoot.
Try matching subRoot against the tree rooted at each node of root. Two trees are identical when their roots match and their left and right subtrees match recursively.
Run checks all cases above. Submit evaluates all test cases.