root of a binary tree. Every node holds a number from 0 to 25 standing for a letter: 0 is a, 1 is b, ..., 25 is z.
Pick any leaf (a node with no children) and read the letters while climbing from it up to the root; that spells a word. Return the lexicographically smallest of all such words.
As a reminder, strings are compared by their first differing letter, and if one is a prefix of the other, the shorter one is smaller: "ab" comes before "aba".root=tree_node([2, 0, 1, None, None, 3, 0]) → 'abc'
There are three leaves, giving "ac", "dbc" and "abc". The smallest is "abc": its second letter "b" already beats "c".
root=tree_node([0, 1]) → 'ba'
The only leaf is "b", and reading up to the root gives "ba".
root=tree_node([25, 0, 0, 1]) → 'az'
The words are "baz" and "az"; "az" is smaller because the comparison looks at the first letter that differs.
root=tree_node([2, 0, 1, None, None, 3, 0])
'abc'
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.