Problem 872 · Easy

Leaf-Similar Trees

Check whether two trees have the same leaf values in the same left-to-right order. The visual collects each tree's leaves in sequence and compares the two lists.

Open the interactive visualisation