Back to course home
0% completed
Solution: Leaf-Similar Trees
Problem Statement
Given the two root nodes root1
and root2
of two different binary trees, return true
if both binary trees are leaf-similar
trees. Otherwise, return false
.
All leaves of the binary tree in left-to-right
order create a leaf sequence
. If both trees have same leaf sequence
, they are considered as leaf-similar
tree.
Examples
Example 1:
- Input: root1 = [5,2,7,1,3,6,8], root2 = [7,5,2,1,3,6,8]
- Expected Output:
True
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible