BFS.py
Approach\nBFS\n# Code\n\nclass Solution:\n    def maxLevelSum(self, root: Optional[TreeNode]) -> int:\n        l=[]\n        ans=[]\n        if root:\n         
# Approach\nBFS\n# Code\n```\nclass Solution:\n    def maxLevelSum(self, root: Optional[TreeNode]) -> int:\n        l=[]\n        ans=[]\n        if root:\n            l.append(root)\n        while l:\n            s=len(l)\n            psh=[]\n            for i in range(s):\n                node=l.pop(0)\n                psh.append(node.val)\n                if node.left:l.append(node.left)\n                if node.right:l.append(node.right)\n            ans.append(sum(psh))\n        return ans.index(max(ans))+1\n```\n\n![](https://i.imgflip.com/5kej8w.jpg)
['Python3']