✅C++ || BEATS 100% || LEVEL ORDER || OPTIMIZED
PLEASE UPVOTE IF YOU FIND MY APPROACH HELPFUL, MEANS A LOT \uD83D\uDE0A\n\nTime Complexity : O(N), where N is the number of nodes in the binary tree.\nSpace Com
**PLEASE UPVOTE IF YOU FIND MY APPROACH HELPFUL, MEANS A LOT \uD83D\uDE0A**\n\n**Time Complexity : `O(N)`, where N is the number of nodes in the binary tree.**\n**Space Complexity : `O(N)`**\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> levelOrder(TreeNode* root) {\n\tif(root==NULL)\n        return {};\n        \n\tqueue<TreeNode*> q;\n\tvector<vector<int> > ans;\n        \n\tq.push(root);\n        \n\twhile(!q.empty()) {\n\t\tint levelSize = size(q);\n\t\tvector<int> currentLevel;\n\t\tfor(int i = 0; i < levelSize; i++) {\n\t\t\tauto top = q.front(); q.pop();\n\t\t\tif(top -> left) q.push(top -> left);\n\t\t\tif(top -> right) q.push(top -> right);\n\t\t\tcurrentLevel.push_back(top -> val);\n\t\t}\n\t\tans.push_back(currentLevel);\n\t}\n\treturn ans;\n}\n};\n```
['C', 'C++']