Smallest String Starting From Leaf
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Every node of the given binary tree holds a value from 0 to 25, standing for the letters 'a' to 'z'.
For each leaf, read the letters on the path from that leaf **up to the root** to form a string. Return the lexicographically smallest of these strings.
Lexicographic order is the usual dictionary order; a string that is a proper prefix of another is the smaller one (for example "ab" < "aba").
Examples
Constraints
- 1 <= number of nodes <= 8500
- 0 <= Node.val <= 25
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.