Skip to content

Latest commit

 

History

History
32 lines (10 loc) · 750 Bytes

File metadata and controls

32 lines (10 loc) · 750 Bytes

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

For example:

Given the following binary tree,

1            




You should return [1, 3, 4].




Credits:Special thanks to @amrsaqr for adding this problem and creating all test cases.
              
              
                Show Tags
                
                
                  
                  
                  Tree
                  
                  
                  Depth-first Search
                  
                  
                  Breadth-first Search