Loading...
Loading...
Loading...
A node with no children is an end team. Print how many end teams the chart has.
Example 1
Input
1 2 3 4 5 null 6
Output
3
The leaves are 4, 5 and 6.
Example 2
Input
9
Output
1
Try the problem first. Open one hint at a time.
A leaf has no left and no right child.
Add the leaves of both sides, and count the node itself when it has no children.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor