[Python] - BFS - Clean & Simple
\n# Code\nPython [1]\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val
\n# Code\n``` Python [1]\n# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def zigzagLevelOrder(self, root: Optional[TreeNode]) -> List[List[int]]:\n        if not root:\n            return []\n        ans = []\n        queue = [root]\n        cnt = 0\n        while queue:\n            temp = queue\n            queue = []\n            level = []\n            for node in temp:\n                if node.left:\n                    queue.append(node.left)\n                if node.right:\n                    queue.append(node.right)\n                level.append(node.val)\n            cnt += 1\n            if cnt & 1 == 1:\n                ans.append(level)\n            else:\n                ans.append(level[::-1])\n        return ans\n\n```
['Python3']