Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Perform BFS per level and keep the last visited node value from each level.
At each level, the last node processed by left-to-right traversal is the rightmost visible node.
Updated Feb 2026