Search
⌘K
Get Premium
Leetcode 2096. Step-By-Step Directions From a Binary Tree Node to Another
Given a binary tree with unique node values, produce the shortest path from start node s to destination t as a string of 'L', 'R', and 'U' moves. The typical approach is to locate their lowest common ancestor and combine the upward moves from s to the LCA ('U's) with the downward L/R moves from the LCA to t (O(n) overall for n up to 1e5).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.