Given a binary tree, return all root-to-leaf paths.
Note
A leaf is a node with no children.
Example
Input:
1 | 1 |
Output: [“1->2->5”, “1->3”]
Explanation: All root-to-leaf paths are: 1->2->5, 1->3
Code
1 | public class TreeNode { |
1 | public List<String> binaryTreePaths(TreeNode root) { |