As reported: Amazon SDE-1 bar raiser round (Nov 2025): one DSA problem plus Leadership Principle scenarios. In the round the moves were printed as
A(left child),B(right child) andC(parent); here they are LeetCode'sL,RandU. The candidate first stored parent pointers and ran BFS while tracking the path; the interviewer then asked for a version without that extra space, and an approach through the lowest common ancestor followed.
You are given the root of a binary tree with n nodes and distinct values, a start value startValue and a destination value destValue. Find the shortest path from the start node to the destination node and return it as a string of moves:
'L'— go to the left child,'R'— go to the right child,'U'— go to the parent.
This is LeetCode 2096 — Step-By-Step Directions From a Binary Tree Node to Another.
Example 1
2
/ \
1 4
start = 1, dest = 4
Output: "UR"
Example 2
root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6
Output: "UURL" 3 → 1 → 5 → 2 → 6
Constraints: 2 ≤ n ≤ 10^5; 1 ≤ Node.val ≤ 10^5, all distinct; startValue ≠ destValue, both present in the tree.
Code runner format: three lines: root in LeetCode's level-order format, then startValue, then destValue. Implement getDirections(root, startValue, destValue); the harness prints the string.