C++ || Simple solution using queue
vector> levelOrder(TreeNode* root) {\n        \n        vector> v;\n        \n        if(root==NULL) return v;\n        \n        queue q;\n        \n        q.
vector<vector<int>> levelOrder(TreeNode* root) {\n        \n        vector<vector<int>> v;\n        \n        if(root==NULL) return v;\n        \n        queue<TreeNode*> q;\n        \n        q.push(root);\n        \n        while(!q.empty())\n        {\n            \n            int n=q.size();\n            vector<int> x(n);\n            \n            for(int i=0;i<n;i++)\n            {\n                TreeNode* temp=q.front();\n                \n                x[i]=q.front()->val;\n                \n                if(temp->left)\n                q.push(temp->left);\n                \n                if(temp->right)\n                q.push(temp->right);\n                \n                q.pop();\n                \n            }\n            \n            v.push_back(x);\n        }\n        \n        return v;\n    }
[]