1602. Find Nearest Right Node in Binary Tree
Last updated
Last updated
https://leetcode.com/problems/find-nearest-right-node-in-binary-tree
Given the root
of a binary tree and a node u
in the tree, return the nearest node on the same level that is to the right of u
, or return null
if u
is the rightmost node in its level.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
The number of nodes in the tree is in the range [1, 105]
.
1 <= Node.val <= 105
All values in the tree are distinct.
u
is a node in the binary tree rooted at root
.