Problem 1602 · Medium

Find Nearest Right Node in Binary Tree

Walk the tree level by level and return the node immediately to the right of u on the same level, or null if u is the rightmost.

Open the interactive visualisation