103.Binary Tree Zigzag Level Order Traversal Posted on 2017-09-24 | In LeetCode Solution 1: accepted 3msBFS. Viration of question 102.Try recursive as well. 1234567891011121314151617181920212223242526272829303132333435public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> result = new ArrayList<List<Integer>>(); if (root == null) { return result; } Queue<TreeNode> queue = new LinkedList<>(); queue.add(root); boolean reverse = false; while (!queue.isEmpty()) { ArrayList<Integer> list = new ArrayList<>(); int size = queue.size(); // get size now as it's dynamic for (int i = 0; i < size; i++) { TreeNode node = queue.poll(); list.add(node.val); if (node.left != null) { queue.add(node.left); } if (node.right != null) { queue.add(node.right); } } if (reverse) { Collections.reverse(list); reverse = false; } else { reverse = true; } result.add(list); } return result;}