Subtree Check in BiTree
BINARY TREE
DEPTH-FIRST SEARCH

Problem

Given the roots of two binary trees, root and subRoot, determine if subRoot is a subtree of root.

A subtree consists of a node in the tree and all its descendants.

Example 1

checkSubtree([1, 2, 3, null, null, 4], [3, 4]) // return true

Example 2

checkSubtree([1, 2, 3, null, null, 4, 5], [3, 4, 6]) // return false
Loading...
Loading...
Loading...