Breadth-First Search pattern
Level Order Sum
Given the root of a binary tree where the root is level 1 and each level below increments by one, return the smallest level number whose nodes have the largest sum of values. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 1161
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Breadth-First SearchLeetCode 1161
Medium
The approach
- 01 BFS by level O(n)O(width) space
What you will learn
- How to read Level Order Sum and spot the breadth-first search pattern in it
- BFS by level: O(n) time, O(width) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Breadth-First Search
See Level Order Sum run, step by step
Sign in and this page opens on the animation, with all 8 Breadth-First Search problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.