Iterative Java , Clean Code 🚀
Use BFS to calculate sum of each level and update it with the result \n> ### Time Complexity : O(N)\n> ### Space Complexity : O(N)\n---\n# Code\n\nclass Solutio
### *Use BFS to calculate sum of each level and update it with the result* \n> ### *Time Complexity : O(N)*\n> ### *Space Complexity : O(N)*\n---\n# Code\n```\nclass Solution {\n    public int maxLevelSum(TreeNode root) {\n        //BFS\n        int result = Integer.MIN_VALUE;\n        int ans = 0;\n        int level = 1;\n        Queue<TreeNode> queue = new LinkedList<>();\n        queue.add(root);\n        while(queue.size() > 0)\n        {\n            int size = queue.size();\n            int sum = 0;\n            for(int i = 0;i<size;i++)\n            {\n                TreeNode curr = queue.poll();\n                sum+=curr.val;\n                if(curr.left!=null)\n                    queue.add(curr.left);\n                if(curr.right!=null)\n                    queue.add(curr.right);\n            }\n            if(result < sum)\n            {\n                result = sum;\n                ans = level;\n            }\n            level++;\n        }\n        return ans;\n    }\n}\n```\n---\n> ## *Please don\'t forget to upvote if you\'ve liked my solution.\uD83D\uDC4D*
['Depth-First Search', 'Breadth-First Search', 'C++', 'Java', 'Python3']