Skip to content

#872 - Leaf-Similar Trees

EasyBinary Tree - DFS
Open on LeetCode

Two binary trees are leaf-similar if their leaf value sequences (left to right) are identical. Given the roots of two binary trees, return true if they are leaf-similar.

InputOutput
root1 = [3,5,1,6,2,9,8,null,null,7,4], root2 = [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8]true
root1 = [1,2,3], root2 = [1,3,2]false

Released under the MIT License.