Leaf Equivalent Trees
Given two binary trees root0 and root1, return whether the sequence of leaves left-to-right in both trees are the same.
Constraints
n ≤ 100,000wherenis the number of nodes inroot0m ≤ 100,000wheremis the number of nodes inroot1
https://binarysearch.com/problems/Leaf-Equivalent-Trees
Examples
Example 1
Input
- root0 =
 
- root1 =
 
Output
- answer = 
False 
Explanation
The left tree has [2, 3] and right has [3, 2]
Example 2
Input
- root0 =
 
- root1 =
 
Output
- answer = 
True 
Explanation
Both trees have leaves [2, 1].
      
      
Leave a comment