Easy JAVA Solution
\n\n# Code\n\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     Tre
\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    public int maxLevelSum(TreeNode root) {\n        if(root==null){\n            return 0;\n        }\n        Queue<TreeNode> q=new LinkedList<>();\n        q.add(root);\n        int count=0;\n        int maxSum=Integer.MIN_VALUE;\n        int maxlevel=0;\n        int curlevel=0;\n        while(!q.isEmpty()){\n            curlevel++;\n            count=q.size();\n            int sum=0;\n            for(int i=0;i<count;i++){\n                TreeNode x=q.remove();\n                    sum+=x.val;\n                if(x.left!=null){\n                    q.add(x.left);\n                }\n                if(x.right!=null){\n                    q.add(x.right);\n                }\n            }\n            if(maxSum<sum){\n                maxSum=sum;\n                maxlevel=curlevel;\n            }\n        }\n        return maxlevel;\n    }\n}\n```
['Java']