Problem 1028 · Hard
Each value carries its depth as leading dashes, so a stack of ancestors rebuilds the tree in one pass.
Open the interactive visualisation