← 返回 amazon 的题目列表Lexicographically Smallest String from Binary Tree
类型:online_judge
Given a binary tree where each node value is an integer representing a letter (using its ord value), collect path values from leaf nodes to the root to form strings, and return the lexicographically smallest one.
Input
root: The root of the binary tree.
Output
The lexicographically smallest string.
Example
Input
0
/ \
1 2
/
3
Output
"dba"
Constraints
The number of nodes in the binary tree is in the range [1, 10^4].
Node values are integers from 0 to 25 representing letters 'a' to 'z'.
Example
Input
0,1,2,3,null,null,null