Coding Challenge

Subtree of Another Tree

Easy
treedfs

Check whether one tree is a subtree of another.

Return true if subRoot appears in root as a subtree with identical structure and values.

Examples

Input: root = [3,4,5,1,2], subRoot = [4,1,2]

Output: true

Constraints

  • Trees may be empty

Preparing your coding workspace...