Subtree of Another Tree

Easy · Trees · about 15 minutes

Asked at Amazon, Meta, Microsoft, Google.

Decide whether subRoot appears inside root: some node of root, taken together with everything below it, must match subRoot exactly in shape and values.

Related guides