Level order Traversal using Queue || 100% faster
\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \n    O(n)\n\n\n\n# Code\n\n/**\n * Definition for a binary tree node.\n * struc
\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    vector<vector<int>> levelOrder(TreeNode* root) {\n        if(root==NULL){\n            vector<vector<int>> v;\n            return v;\n        }\n        queue<TreeNode*>q;\n        q.push(root);\n        q.push(NULL);\n        vector<vector<int>>ans;\n        vector<int>temp;\n        while(!q.empty()){\n            TreeNode* node=q.front();\n            q.pop();\n            if(node){\n                if(node->left) q.push(node->left);\n                if(node->right) q.push(node->right);\n                \n                temp.push_back(node->val);\n            }else{\n                if(!q.empty()){\n                    q.push(NULL);\n                    ans.push_back(temp);\n                    temp.resize(0);\n                }\n            }\n            \n        }\n        ans.push_back(temp);\n        return ans;\n    }\n};\n```
['Tree', 'Queue', 'Binary Tree', 'C++']