NeetCode #789LC-2285MediumGreedy
← Back to All Problems

#789 · #2285 · Maximum Total Importance of Roads(道路的最大总重要性)

📌 Problem Statement & Constraints

You are given an integer n (cities numbered 0..n-1) and roads where roads[i] = [a, b] is a bidirectional road. Assign each city a unique value from 1 to n; the importance of a road is the sum of its two cities' values, and the total importance is the sum over all roads. Return the maximum total importance. Constraints: 2 <= n <= 5 * 10^4, 1 <= roads.length <= 5 * 10^4, 0 <= a, b < n.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!