C++ | Queue | 0ms Faster than 100%
\n\n\n\nclass Solution {\npublic:\n    \n    vector<vector<int>> levelOrder(TreeNode* root) {\n        vector<vector<int>> ans;\n        vector<int> add;\n     
![image](https://assets.leetcode.com/users/images/3f531236-b269-4184-a07e-4af7b25a0b33_1634985679.630573.png)\n\n\n```\nclass Solution {\npublic:\n    \n    vector<vector<int>> levelOrder(TreeNode* root) {\n        vector<vector<int>> ans;\n        vector<int> add;\n        if(!root)\n            return ans;\n        \n        queue<TreeNode*> mq;\n        mq.push(root);\n\n        while(mq.size() > 0){\n            int count = mq.size();\n            for(int i = 0; i < count; i++){\n                root = mq.front();\n                mq.pop();\n                add.push_back(root->val);\n\n                if(root->left != NULL)\n                    mq.push(root->left);\n\n                if(root->right != NULL)\n                    mq.push(root->right);\n                }\n                ans.push_back(add);\n                add.clear();\n            }\n    \n        return ans;\n    }\n};\n```\n\nHope you liked it , kindly upvote !!\n\nHappy Coding \uD83E\uDD17
['Breadth-First Search', 'Queue', 'C', 'C++']