/**
 * Definition for binary tree
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
public class Solution {
    public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
        List<List<Integer>> result = new LinkedList<List<Integer>>();
        if (root == null)
            return result;
        
        List<List<TreeNode>> levelNodes = new ArrayList<List<TreeNode>>();
        List<TreeNode> level = new ArrayList<TreeNode>();
        level.add(root);
        levelNodes.add(level);
        boolean zig = true;
        int i = 0;
        while (i < levelNodes.size()) {
            List<Integer> levelRst = new LinkedList<Integer>();
            level = new ArrayList<TreeNode>();
            
            List<TreeNode> traversal = levelNodes.get(i);
            for (TreeNode node : traversal) {
                levelRst.add(node.val);
            }
            Collections.reverse(traversal);
            for (TreeNode node : traversal) {
                
                if (zig) {
                    if (node.right != null)
                        level.add(node.right);
                    if (node.left != null)
                        level.add(node.left);
                } else {
                    if (node.left != null)
                        level.add(node.left);
                    if (node.right != null)
                        level.add(node.right);
                }
            }
            result.add(levelRst);
            if (!level.isEmpty())
                levelNodes.add(level);
            zig = zig ? false : true;
            i++;
        }
        return result;
    }
}
@@ -160,16 +160,648 @@
 * %7D%0A */%0A
+// recursive%0Apublic class Solution %7B%0A    public List%3CList%3CInteger%3E%3E zigzagLevelOrder(TreeNode root) %7B%0A        List%3CList%3CInteger%3E%3E res = new ArrayList%3CList%3CInteger%3E%3E();%0A        zigzagHelper(root, res, 0);%0A        return res;%0A    %7D%0A    %0A    private void zigzagHelper(TreeNode root, List%3CList%3CInteger%3E%3E res, int level) %7B%0A        if (root == null) return;%0A        if (res.size() == level) res.add(new ArrayList%3CInteger%3E());%0A        if (level %25 2 == 0) res.get(level).add(root.val);%0A        else res.get(level).add(0, root.val);%0A        zigzagHelper(root.left, res, level + 1);%0A        zigzagHelper(root.right, res, level + 1);%0A    %7D%0A%7D%0A%0A
 public c

BinaryTreeZigzagLevelOrderTraversal.java. add recursive solution