How would you like to learn today?
Visualize algorithms in real time, explore them step by step, or challenge yourself with a test.Choose a path to focusโor scroll down to preview all options.
Visualize the algorithm step-by-step with interactive animations in real time.
Read the full explanation, examples, and starter code at your own pace.
Drag and arrange the algorithm steps in the correct execution order.
๐ง Select Active to activate
Follow every state change, comparison, and transformation as the execution unfolds in real time.
๐ Select Passive to activate
Difficulty: ๐ก Medium
Topics: Binary Tree, BFS, DFS
You are given the root of a binary tree.
๐ Your task is to find the smallest level x such that the sum of all node values at level x is maximum.
Input
root = [1,7,0,7,-8,null,null]
Explanation
| Level | Nodes | Sum |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 7, 0 | 7 |
| 3 | 7, -8 | -1 |
โ Maximum sum = 7 at level 2
Output
2
Input
root = [989,null,10250,98693,-89388,null,null,null,-32127]
Output
2
Visualizing level-by-level traversal makes this problem much easier to understand. This is a perfect candidate for step-by-step tree visualization!
โ Written by Saurabh Patil โข B.Tech CSE โข Software Developer๐ฏ Select Challenge to activate
Drag and arrange the algorithm steps in the correct execution order instead of spending time typing code letter by letter.
The algorithm is divided into three logical parts. Carefully rearrange each section in the correct order to form a complete and valid solution.
Understand Below AlgorithmGreen text means the instruction is placed in the correct position.
Red text means the instruction is in the wrong position.
Instructions with the same background color indicate particular blocks start and end.
A tick mark means the instruction is correct and locked.
๐ Locked steps cannot be moved. Only unlocked steps are draggable.
๐ Enable sound for swap feedback and completion effects.