Question: A path is a route that connects two nodes, and the length of a path is the number of steps on the route. Your task

A path is a route that connects two nodes, and the length of a path is the number of steps on the route. Your task is to compute the sum of the lengths of all paths connecting two leaves of a tree. In the code template example, there are three such paths: Here the path lengths are 3, 3 , and 2 , and so the correct answer is 3+3+2=8. You may assume that the tree has at most 100 nodes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
