C++✅✅ | Level Order Traversal + BFS | Faster🧭 than 100%🔥 | Clean & Concise Code |
\n\n# Code\n# Please Do Upvote!!!!\n##### Connect with me on Linkedin -> https://www.linkedin.com/in/md-kamran-55b98521a/\n\n\n\nclass Solution {\npublic:\n\n  
\n\n# Code\n# Please Do Upvote!!!!\n##### Connect with me on Linkedin -> https://www.linkedin.com/in/md-kamran-55b98521a/\n```\n\n\nclass Solution {\npublic:\n\n    vector<vector<int>> zigzagLevelOrder(TreeNode* root) {\n        \n         vector<vector<int>>res;\n\n        if(root == NULL) return res;\n\n        queue<TreeNode*>q;\n        q.push(root);\n        int cnt = -1;\n\n        while(!q.empty())\n        {\n          int n = q.size();\n\n          vector<int>l;\n\n          for(int i = 0; i < n; ++i)\n          {\n            \n            auto temp = q.front();\n            q.pop();\n\n            if(temp->left!=NULL) q.push(temp->left);\n            if(temp->right!=NULL) q.push(temp->right);\n\n            l.push_back(temp->val);\n\n          }\n\n          cnt++;\n         \n          if(cnt % 2 != 0) reverse(l.begin(),l.end());\n\n          res.push_back(l);\n          \n        }\n\n        return res;\n    }\n};\n\n\n\n```\n![b62ab1be-232a-438f-9524-7d8ca4dbd5fe_1675328166.1161866.png](https://assets.leetcode.com/users/images/98b7adbc-5abf-45f7-9b5b-538574194654_1676344687.6513524.png)
['C++']