private static void Helper(LeetCode199TreeNode root, int level)
        {
            if (root == null)
            {
                return;
            }

            if (level == rightSideNodes.Count)
            {
                rightSideNodes.Add(root.val);
            }

            if (root.right != null)
            {
                Helper(root.right, level + 1);
            }
            if (root.left != null)
            {
                Helper(root.left, level + 1);
            }
        }
 public static IList <int> RightSideView(LeetCode199TreeNode root)
 {
     Helper(root, 0);
     return(rightSideNodes);
 }
 public LeetCode199TreeNode(int val = 0, LeetCode199TreeNode left = null, LeetCode199TreeNode right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }