A concise and easy understanding Java solution
public class Solution {\n    public List> zigzagLevelOrder(TreeNode root) {\n        List> res = new ArrayList<>();\n        if(root == null) return res;\n\n   
public class Solution {\n    public List<List<Integer>> zigzagLevelOrder(TreeNode root) {\n        List<List<Integer>> res = new ArrayList<>();\n        if(root == null) return res;\n\n        Queue<TreeNode> q = new LinkedList<>();\n        q.add(root);\n        boolean order = true;\n        int size = 1;\n\n        while(!q.isEmpty()) {\n            List<Integer> tmp = new ArrayList<>();\n            for(int i = 0; i < size; ++i) {\n                TreeNode n = q.poll();\n                if(order) {\n                    tmp.add(n.val);\n                } else {\n                    tmp.add(0, n.val);\n                }\n                if(n.left != null) q.add(n.left);\n                if(n.right != null) q.add(n.right);\n            }\n            res.add(tmp);\n            size = q.size();\n            order = order ? false : true;\n        }\n        return res;\n    }\n}
[]