Java-BFS solution-1 pass
Traverse the tree using BFS and keep a track of maxLevelSum at its corresponding level. Update at every level.\n\nclass Solution {\n    public int maxLevelSum(T
Traverse the tree using BFS and keep a track of maxLevelSum at its corresponding level. Update at every level.\n```\nclass Solution {\n    public int maxLevelSum(TreeNode root) {\n        Queue<TreeNode> queue = new LinkedList<>();\n        queue.offer(root);\n        int maxLevelSum = Integer.MIN_VALUE, levels = 1, maxLevel = 1;\n        \n        while(!queue.isEmpty()) {\n            int size = queue.size();\n            int localSum = 0;\n            for(int i=0; i<size; i++)   {\n                TreeNode curr = queue.poll();\n                localSum += curr.val;\n                \n                if(curr.left != null) queue.offer(curr.left);\n                if(curr.right != null) queue.offer(curr.right);\n            }\n            \n            if(maxLevelSum < localSum)  {\n                maxLevel = levels;\n                maxLevelSum = localSum;\n            }\n            \n            levels++;\n        }\n        \n        return maxLevel;\n    }\n}\n```
[]