#3547
Maximum Sum of Edge Values in a Graph
master · 1850 · lc hard +32 · 35.7% accepted · 50 likes · top 13%
Description
An undirected connected graph has n nodes (each with degree at most 2) and m edges given by edges[i] = [ai, bi]. Assign distinct integers 1 through n to the nodes.
Each edge\'s value is the product of its endpoints\' assigned values; the score is the sum over all edges.
Return the maximum achievable score.
Code
1
2
3