Nodes Visible When Viewing a Binary Tree From One Side

Algorithm · C3.ai · Medium

You are handed the root of a binary tree. Picture yourself standing to the right of the tree and looking at it; for each level, only one node can be seen from that position. Return the values of those visible nodes, listed from the top level down to the bottom level. Examples Example 1 Example 2

Loading the rest of the question…