257. Binary Tree Paths
Description
Given a binary tree, return all root-to-leaf paths.
Note: A leaf is a node with no children.
Constraints
Approach
Links
GeeksforGeeks
ProgramCreek
YouTube
Examples
Input: [1, 2, 3, null, 5]
Output: ["1->2->5", "1->3"]
Input: [1, 2, 3, null, 5, 6, 7, 8, 9]
Output: ["1->2->5->8", "1->2->5->9", "1->3->6", "1->3->7"]
Input: [1]
Output: ["1"]
Solutions
Follow up
Last updated
Was this helpful?