@@ -0,0 +1,1764 @@
+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://oj.leetcode.com/problems/binary-tree-level-order-traversal/%0A */%0Apublic class Problem102 %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%3CList%3CInteger%3E%3E levelOrder(TreeNode root) %7B%0A        class LevelNode %7B%0A            int level;%0A            TreeNode node;%0A            %0A            public LevelNode(int level, TreeNode node) %7B%0A                this.level = level;%0A                this.node = node;%0A            %7D%0A        %7D%0A        %0A        List%3CList%3CInteger%3E%3E result = new ArrayList%3C%3E();%0A        if (root == null) %7B%0A            return result;%0A        %7D%0A        Map%3CInteger, List%3CInteger%3E%3E map = new HashMap%3C%3E();%0A        LinkedList%3CLevelNode%3E linkedList = new LinkedList%3C%3E();%0A        linkedList.add(new LevelNode(0, root));%0A        while (!linkedList.isEmpty()) %7B%0A            LevelNode n = linkedList.removeFirst();%0A            if (!map.containsKey(n.level)) %7B%0A                List%3CInteger%3E list = new ArrayList%3C%3E();%0A                list.add(n.node.val);%0A                map.put(n.level, list);%0A            %7D else %7B%0A                map.get(n.level).add(n.node.val);%0A            %7D%0A            if (n.node.left != null) %7B%0A                linkedList.addLast(new LevelNode(n.level+1, n.node.left));%0A            %7D%0A            if (n.node.right != null) %7B%0A                linkedList.addLast(new LevelNode(n.level+1, n.node.right));%0A            %7D%0A        %7D%0A        for (int i = 0; i %3C map.size(); i++) %7B%0A            result.add(map.get(i));%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A

Solve problem 102