class Solution { public: vector<vector<int>> levelOrder(TreeNode* root) { vector<vector<int>> v2; if(!root) return v2; vector<vector<int>> v1; queue<TreeNode *>q1; q1.push(root); while(!q1.empty()){ vector<int> v; int sz=q1.size(); while(sz--){ //vector<int> v; TreeNode *cur = q1.front(); q1.pop(); if(cur->left) q1.push(cur->left); if(cur->right)q1.push(cur->right); v.push_back(cur->val); //v1.push_back(v); } v1.push_back(v); } return v1; } };