Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can you process nodes from smallest to largest value?
Try to build the graph from nodes with the smallest value to the largest value.
May union find help?
Solve with full IDE support and test cases