Return every root-to-leaf path as a string like "1->2->5". List the paths from left to right: all the paths through the left subtree come before the paths through the right subtree.
The tests write a tree as a level-order list (row by row, left to right) with None for a missing child: [3, 9, 20, None, None, 15, 7] is a root 3 with children 9 and 20, where 20 has children 15 and 7.
For [1, 2, 3, None, 5] the answer is ["1->2->5", "1->3"].
Example 1
Input:
root_to_leaf_paths(root) # root = [1, 2, 3, None, 5]
Output:
['1->2->5', '1->3']
Example 2
Input:
root_to_leaf_paths(root) # root = [1]
Output:
['1']
0 <= number of nodes <= 20000-100 <= val <= 100No results yet
Run your code to check it against the examples, or submit to run every test.