```
class Solution(object):
def zigzagLevelOrder(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
if not root:
return []
order = 1
res = []
queue = [root]
while queue:
tempQueue = []
level = []
for node in queue:
level.append(node.val)
if node.left:
tempQueue.append(node.left)
if node.right:
tempQueue.append(node.right)
res.append(level[::order])
order *= -1
queue = tempQueue
return res
```