Binary Tree Paths
Given the root of a binary tree, return all root-to-leaf paths in any order.

30:00

Binary Tree Paths
easy
Topics
Companies

Given the root of a binary tree, return all root-to-leaf paths in any order.

Example 1:
Input: {"root":[1,2,3,null,5]}
Output: ["1->2->5","1->3"]
Constraints:
  • The number of nodes is in the range [1,100][1, 100].

  • 100Node.val100-100 \leq \text{Node.val} \leq 100

Input
arr ={"root":[1,2,3,null,5]}

1

2

3

5

Variables
VariableValue
path
DepthFunction Call
Stack empty
0/10