....
class Solution {
public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
Queue<TreeNode> q = new LinkedList<TreeNode>();
List<List<Integer>> levelList = new ArrayList();
List<Integer> list ;
if(root == null)
return levelList;
q.add(root);
int level = 0;
int nodecount;
while(!q.isEmpty()){
nodecount = q.size();
list = new ArrayList();
for(int i=0;i<nodecount;i++){
TreeNode node = q.remove();
if(level%2 == 0)
list.add(node.val);
else
list.add(0,node.val);
if(node.left != null)
q.add(node.left);
if(node.right != null)
q.add(node.right);

} levelList.add(list); level++; } return levelList; }

}
....