🚀Simplest Solution🚀||🔥Full Explanation||🔥C++🔥|| Python3
Consider\uD83D\uDC4D\n\n                    Please Upvote If You Find It Helpful\n\n# Intuition\nIntuition of this problem is very simple.\nWe use the Level Ord
# Consider\uD83D\uDC4D\n```\n                    Please Upvote If You Find It Helpful\n```\n# Intuition\nIntuition of this problem is very simple.\nWe use the **Level Order Traversal** of Binary tree.\nFor the Zig Zag Movement we are using a variable `level` when it is **zero**  we **move from Left to Right** and when it is `one` we move from **Right to Left**.\nFor Level order traversal I am using a **Queue**.\nInitially we push `root` element in the queue. Traverse all elements of the tree.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : BFS, Level Order Traversal\n    Example : `root` = [3,9,20,null,null,15,7]\n\n    Initially `queue` = [3], level = 0\n    In first pass\n        size = 1 `queue` = [3]\n        `curr[0]` = 3\n        We push 3->left and 3->right in queue\n        `queue` = [9, 20]\n        So our loop only run 1 time beacuase size is 1.\n\n    Now we push curr to `output` vector `output` = [[3]]\n    Now `level` = 1\n\n    In Second pass\n        size = 2 `queue` = [9, 20]\n        `curr[1]` = 20\n        `curr[0]` = 9\n        We push 20->left and 20->right in queue\n        `queue` = [15, 7]\n        And 9->left = NULL , 9->right = NULL so we do not push it.\n        So our loop run 2 times beacuase size is 2.\n\n    Now we push curr to `output` vector `output` = [[3], [20, 9]]\n    Now `level` = 0\n\n    In this way me iterate for the 15 and 7.\n    So answer is `[[3], [20, 9], [15, 7]]`\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(W) width of the tree\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```C++ []\nclass Solution {\npublic:\n    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n        \n        if (!root) return {};\n        \n        queue<TreeNode*> q;\n        vector<vector<int>> out;\n            \n        q.push(root);  \n        int level = 0; /* to alternate levels, or a bool variable */\n        \n        while (!q.empty()) {\n            \n            int sz = q.size();  \n            vector<int> curr(sz); \n            \n            for (int i = 0; i < sz; i++) {\n                \n                TreeNode* tmp = q.front();\n                q.pop();\n                \n                if (level == 0) {\n                    curr[i] = tmp->val; // odd level, insert like 0, 1, 2, 3 etc. \n                } else {\n                    curr[sz - i - 1] = tmp->val; /* even level insert from end. 3, 2, 1, 0. (sz - i - 1) to get the index from end */\n                }\n                \n                if (tmp->left) q.push(tmp->left);\n                if (tmp->right) q.push(tmp->right);\n            }\n            out.push_back(curr); // now push the level traversed to output vector\n            level = !level; // toggle the level using negation. or level == 0 ? level = 1 : level = 0;\n        }\n        return out;\n    }\n};\n\n```\n```python []\nfrom queue import Queue\nclass Solution:\n    def zigzagLevelOrder(self, A: TreeNode) -> List[List[int]]:\n        if not A:\n            return []\n        queue = Queue()\n        queue.put(A)\n        output = []\n        curr = []\n        level = 0\n        while not queue.empty():\n            size = queue.qsize()\n            curr = []\n            for i in range(size):\n                temp = queue.get()\n                if level % 2 == 0:\n                    curr.append(temp.val)\n                else:\n                    curr.insert(0, temp.val)\n                if temp.left:\n                    queue.put(temp.left)\n                if temp.right:\n                    queue.put(temp.right)\n            level = not level\n            output.append(curr)\n        return output\n```\n```\n                    Give a \uD83D\uDC4D. It motivates me alot\n```\nLet\'s Connect On [Linkedin](https://www.linkedin.com/in/naman-agarwal-0551aa1aa/)
['Tree', 'Breadth-First Search', 'Binary Tree', 'C++', 'Python3']