Faster than 100% || Simple Level Order Solution
Code\n\nclass Solution {\npublic:\n    int maxLevelSum(TreeNode* root) {\n        queue<TreeNode*> q;\n        q.push(root);\n        int level=0,maxlevel=0,max
# Code\n```\nclass Solution {\npublic:\n    int maxLevelSum(TreeNode* root) {\n        queue<TreeNode*> q;\n        q.push(root);\n        int level=0,maxlevel=0,maxsum=INT_MIN;\n        while(!q.empty()){\n            int x=q.size();\n            level++;\n            int levelSum=0;\n            for(int i=0;i<x;i++){\n                TreeNode* curr=q.front();\n                q.pop();\n                levelSum+=curr->val;\n                if(curr->left){\n                    q.push(curr->left);\n                }\n                if(curr->right){\n                    q.push(curr->right);\n                }\n            }\n            if(maxsum<levelSum){maxlevel=level;maxsum=levelSum;}\n        }\n        root->left=NULL;root->right=NULL;\n        return maxlevel;\n    }\n};\n```
['C++']