Practice Step-By-Step Directions From a Binary Tree Node to Another
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2096
LeetCode ProblemStep-By-Step Directions From a Binary Tree Node to Another
Problem Statement
Find the shortest path from the node with startValue to the different node with destValue in root. Node values are unique. Return a string describing each step: L enters the left child, R enters the right child, and U goes to the parent.
Source: Step-By-Step Directions From a Binary Tree Node to Another on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6
Output
"UURL"
# Example 2
Input
root = [2,1], startValue = 2, destValue = 1
Output
"L"
Constraints
The number of nodes in the tree is n.
2 <= n <= 10^5
1 <= Node.val <= n
All the values in the tree are unique.
1 <= startValue, destValue <= n
startValue != destValue
Related LeetCode Problems
Practice more problems similar to Step-By-Step Directions From a Binary Tree Node to Another.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.