Binary Tree Maximum Level Sum

📅 Day 60 of #100DaysOfLeetCode 🌳 Problem: 1161. Maximum Level Sum of a Binary Tree 🟡 Difficulty: Medium 🧠 Problem Summary Given a binary tree, each level has a sum of its node values. The task is to find the smallest level number whose node sum is maximum. 💡 Approach (BFS / Level Order Traversal) Use a queue to traverse the tree level by level For each level: Calculate the sum of all nodes at that level Compare it with the maximum sum found so far Track the level that gives the maximum sum If multiple levels have the same sum, return the smallest level ⏱️ Complexity Analysis Time Complexity: O(n) Space Complexity: O(n) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday

  • text

To view or add a comment, sign in

Explore content categories