Skip to content

Latest commit

 

History

History
69 lines (28 loc) · 927 Bytes

README_EN.md

File metadata and controls

69 lines (28 loc) · 927 Bytes

Description

T1 and T2 are two very large binary trees, with T1 much bigger than T2. Create an algorithm to determine if T2 is a subtree of T1.

A tree T2 is a subtree of T1 if there exists a node n in T1 such that the subtree of n is identical to T2. That is, if you cut off the tree at node n, the two trees would be identical.

Example1:

 Input: t1 = [1, 2, 3], t2 = [2]

 Output: true

Example2:

 Input: t1 = [1, null, 2, 4], t2 = [3, 2]

 Output: false

Note:

  1. The node numbers of both tree are in [0, 20000].

Solutions

Python3

Java

...