Directions to a Value
You are given the root of a binary tree. Return the route from the root to the node holding target as a string of "L" (go to the left child) and "R" (go to the right child) letters. If target is the root's own value, return the empty string "". If no node holds target, return None. All values are distinct.
Trees appear in the tests in level order, with null for a missing child, like [3,9,20,null,null,15,7]. Each node is a TreeNode with .val, .left and .right; the class is already defined for you.
Example 1
root [5,1,2,3,null,6,4]
target 6
returns "RL"
Root 5, right to 2, left to 6: "RL".
Constraints
0 <= number of nodes <= 100-100 <= node.val <= 100- Values are distinct.
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.