Short 8ms C++ solution with queue
\tclass Solution {\n    public:\n        vector> levelOrder(TreeNode* root) {\n            if (!root) { return {}; }\n            vector row;\n            vecto
\tclass Solution {\n    public:\n        vector<vector<int>> levelOrder(TreeNode* root) {\n            if (!root) { return {}; }\n            vector<int> row;\n            vector<vector<int> > result;\n            queue<TreeNode*> q;\n            q.push(root);\n            int count = 1;\n\t\t\t\n\t\t\twhile (!q.empty()) {\n                if (q.front()->left) { q.push(q.front()->left); }\n                if (q.front()->right) { q.push(q.front()->right); }\n                row.push_back(q.front()->val), q.pop();\n                if (--count == 0) {\n                    result.emplace_back(row), row.clear();\n                    count = q.size();\n                }\n            }\n            return result;\n        }\n    };
['C++']