Beats 87.96%of users with Java
\n\n# Code\n\nclass Solution {\n    int  mxSum=Integer.MIN_VALUE;\n    int minLevel=1;\n    public int maxLevelSum(TreeNode root) {\n     int level=1; \n     Qu
\n\n# Code\n```\nclass Solution {\n    int  mxSum=Integer.MIN_VALUE;\n    int minLevel=1;\n    public int maxLevelSum(TreeNode root) {\n     int level=1; \n     Queue<TreeNode> queue=new LinkedList<TreeNode>();\n     queue.offer(root);\n     while(queue.size()>0){\n         int size=queue.size();\n         int sum=0;\n         while(size-->0){\n             TreeNode node=queue.remove();\n             sum+=node.val;\n             if(node.left!=null)\n             queue.offer(node.left);\n             if(node.right!=null)\n             queue.offer(node.right);\n         }\n         if(sum>mxSum){\n             minLevel=level;\n             mxSum=sum;\n         }\n         level++;   \n     }\n     return minLevel ;\n    }\n}\n```
['Java']