We’re preparing your current view and syncing the latest data.
Given a binary tree, return all root-to-leaf paths in any order. Each path should be represented as a string in the format "root->node->...->leaf". A leaf is a node with no children.
The input is the root of a binary tree.
Return a list of strings, each string representing a root-to-leaf path.
The number of nodes in the tree is in the range [1, 100]. The value of each node is in the range [-100, 100].
Example 1
Input
[1,2,3,null,5]
Output
1->2->5,1->3
Explanation
There are two paths from root to leaf: 1->2->5 and 1->3.