Compute sums and maximum path in a tree | Uber Interview Question