Loading...
Loading...
Loading...
A company chart is a binary tree: each department has at most two sub-departments. Count all the departments in the chart.
Example 1
Input
1 2 3 4 5
Output
5
Five departments.
Example 2
Input
null
Output
0
Try the problem first. Open one hint at a time.
A missing child counts as zero.
Count the node itself plus the count of each side.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor