Print all root to leaf paths

You are given a binary tree. Find all paths from root to leaves of the binary tree.



Input Format

The only argument given is the root pointer of tree A.

Output Format

Return all paths from root to leaf.

Constraints

1 <= number of nodes <= 50000
0 <= A[i] <= 10^9 

For Example

Input 1:
          5
         / \
        4   8
       /   / \
      11  13  4
     /      / 
    7      5  
Output 1:
 [
   [5,4,11,7],
   [5,8,13],
   [5,8,4,5]
]    
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Print all root to leaf paths on Interview Code Editor
Sign Up
to access hints and editorial solutions for Print all root to leaf paths

Discussion


Loading...
Click here to start solving coding interview questions