1602. Find Nearest Right Node in Binary Tree
https://leetcode.com/problems/find-nearest-right-node-in-binary-tree
Description
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 <= 105All values in the tree are distinct.
uis a node in the binary tree rooted atroot.
ac
Last updated
Was this helpful?