Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can we use DFS based approach here?
For each edge, find two sums: one including the edge and one excluding it.
Solve with full IDE support and test cases