52: Binary tree right side view

Given a binary tree, find out a right side view

 

Example 1

Input:        8       <--- 
             / \
            2   3     <---
           /   / \
          4   5   1   <---
             /  
            2         <---

Output: [8, 3, 1, 2]

Example 2

Input:     2   
          / \  
         5   3 

Output: [2, 3]
Difficulty:Medium
Topic:Tree
Problem #:52