Leaderboard
Showing:
Number of root to leaf paths
Medium Accuracy: 52.12% Submissions: 4952 Points: 4

Given a binary tree, you need to find the number of all root to leaf paths along with their path lengths.

Example 1:

Input:
3 2 4

Output:
2 2 $

Explanation :
There are 2 roots to leaf paths
of length 2.     

Example 2:

Input:
10 20 30 40 60

Output:
2 1 $3 2 $

Explanation:
There is 1 root leaf paths of
length 2 and 2 roots to leaf paths
of length 3.

Your Task:
Your task is to complete the function pathCounts that prints the number of all root to leaf paths along with their path length separated by space.

Constraints:
1 <= T <= 30
1 <= Number of nodes <= 100
1 <= Data of a node <= 1000

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Number of root to leaf paths

Output Window