Try every possible pair of nodes and find the path between them. Calculate path sums.
With nodes, there are pairs. Finding the path between each pair takes . Total: .
Can you compute the maximum path sum in a single traversal?
The trap
Try every possible pair of nodes and find the path between them. Calculate path sums.
With nodes, there are pairs. Finding the path between each pair takes . Total: .
Can you compute the maximum path sum in a single traversal?