Easy to understand C++ Solution
Runtime: 4 ms, faster than 93.67% of C++ online submissions for Binary Tree Level Order Traversal.\nMemory Usage: 13.7 MB, less than 98.59% of C++ online submis
Runtime: 4 ms, faster than 93.67% of C++ online submissions for Binary Tree Level Order Traversal.\nMemory Usage: 13.7 MB, less than 98.59% of C++ online submissions for Binary Tree Level Order Traversal.\n\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n    vector<vector<int>> levelOrder(TreeNode* root) {\n        \n        if(root == nullptr) return {};\n        vector<vector<int>> res;\n        queue<TreeNode*> q;\n        q.push(root);\n        \n        while(!q.empty())\n        {\n            int count = q.size();\n            vector<int> temp;\n            while(count--)\n            {\n                TreeNode* curr = q.front();\n                q.pop();\n                temp.push_back(curr->val);\n                if(curr->left) q.push(curr->left);\n                if(curr->right) q.push(curr->right);\n            }\n            \n            res.push_back(temp);\n        }\n        return res;\n    }\n};\n
[]