root of a binary tree. A leaf is a node with no children.
For every leaf, write down the route from the root to it as a string: the node values in order, joined by an arrow -> with no spaces, such as "8->5->2".
Return a list of all these strings, one per leaf. The strings may come in any order.root=tree_node([8, 3, 5, None, None, 2, 7]) → ['8->3', '8->5->2', '8->5->7']
The leaves are 3, 2 and 7. The routes to them are 8->3, 8->5->2 and 8->5->7.
root=tree_node([-4, None, 6]) → ['-4->6']
The only leaf is 6, reached by -4->6.
root=tree_node([12]) → ['12']
The root is itself a leaf, so the route is just one node.
Node.val ≤ 1000root=tree_node([8, 3, 5, None, None, 2, 7])
['8->3', '8->5->2', '8->5->7']
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.