Simple C++ Solution Using Level Order Traversal
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int maxLevelSum(TreeNode* root) {\n        queue<TreeNode *> q;\n        q.push(root);\n        int j=1,k=1, maxi=INT_MIN;\n        while(!q.empty())\n        {\n            int s=q.size();\n            \n            vector<int> v;\n            for(int i=0;i<s;i++)\n            {\n                TreeNode * tmp=q.front();\n                q.pop();\n                if(tmp->left) q.push(tmp->left);\n                if(tmp->right) q.push(tmp->right);\n                v.push_back(tmp->val);\n            }\n            int sum=0;\n            sum=accumulate(v.begin(),v.end(),sum);\n            if(sum>maxi)\n              {\n                  maxi=sum;\n                  k=j;\n              }\n            j++;\n        }\n\n        return k;\n    }\n};\n```
['C++']