🏆C++ || Easy BFS
Code\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : 
# 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 level=0;\n        int mx= INT_MIN;\n        int level_number;\n        while(q.size()){\n            int k=q.size();\n            level++;\n            int sum=0;\n            while(k--){\n                auto x =q.front();\n                q.pop();\n                sum+=x->val;\n                if(x->left!=NULL){\n                    q.push(x->left);\n                }\n                if(x->right!=NULL){\n                    q.push(x->right);\n                }\n            }\n            if(mx<sum){\n                mx=sum;\n                level_number=level;\n            }\n        }\n        return level_number;\n    }\n};\n```\n![upvote (2).jpg](https://assets.leetcode.com/users/images/d06b0a6a-5677-40fb-a8d7-eedac5d67a5f_1686811022.2489357.jpeg)\n
['C++']