Consider all the leaves of a binary tree in left-to-right order; the values of those leaves form a leaf value sequence. Two binary trees are leaf-similar if their leaf value sequences are the same. Determine if two binary trees with given head nodes are leaf-similar.
Click Run to execute sample tests.