@@ -0,0 +1,1493 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * https://leetcode.com/problems/binary-tree-right-side-view/%0A */%0Apublic class Problem199 %7B%0A    public static class TreeNode %7B%0A        int val;%0A        TreeNode left;%0A        TreeNode right;%0A%0A        TreeNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A    %0A    public List%3CInteger%3E rightSideView(TreeNode root) %7B%0A        class TreeNodeLevel %7B%0A            TreeNode node;%0A            int level;%0A            %0A            public TreeNodeLevel(TreeNode node, int level) %7B%0A                this.node = node;%0A                this.level = level;%0A            %7D%0A        %7D%0A        List%3CInteger%3E result = new ArrayList%3C%3E();%0A        if (root == null) %7B%0A            return result;%0A        %7D%0A        LinkedList%3CTreeNodeLevel%3E list = new LinkedList%3C%3E();%0A        list.add(new TreeNodeLevel(root, 1));%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        while (!list.isEmpty()) %7B%0A            TreeNodeLevel n = list.remove();%0A            map.put(n.level, n.node.val);%0A            if (n.node.left != null) %7B%0A                list.add(new TreeNodeLevel(n.node.left, n.level+1));%0A            %7D%0A            if (n.node.right != null) %7B%0A                list.add(new TreeNodeLevel(n.node.right, n.level+1));%0A            %7D%0A        %7D%0A        for (int i = 1; i %3C= map.size(); i++) %7B%0A            result.add(map.get(i));%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A

Solve problem 199