✅Python3 30ms 🔥🔥 easiest solution
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing BFS level order traversal we can solve this.\n\n# Approach\n Describe your approa
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing BFS level order traversal we can solve this.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- very simple approach.\n- traverse left most node then right nodes.\n- while traversing keep track of level.\n- if level % 2 == 1 then we do right to left, else left to right.\n- while traversing if we\'re on odd level then use stack like structure, like append element at initial index.\n- while traversing if we\'re on even level then use queue like structure and append element at last index.\n- that\'s it.\n- now return values of of dictionary we made in list form.\n\n# Complexity\n- Time complexity: O(height of tree+N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def zigzagLevelOrder(self, root: Optional[TreeNode]) -> List[List[int]]:\n        ans = dict()\n        def bfs(curr=root, level = 0):\n            nonlocal ans\n            if curr != None:\n                if level % 2 == 1: # go right to left, used stack\n                    if level in ans.keys():\n                        ans[level].insert(0, curr.val)\n                    else:\n                        ans[level] = [curr.val]\n                else: #go left to right, used queue\n                    if level in ans.keys():\n                        ans[level].append(curr.val)\n                    else:\n                        ans[level] = [curr.val]\n                bfs(curr.left, level + 1)\n                bfs(curr.right, level + 1)\n            return\n        bfs()\n        return ans.values()\n```\n# Please Like and comment below.\n# (>\u203F\u25E0)\u270C
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree', 'Python3']