Skip to content

Commit

Permalink
Solution to today's problem
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Jun 28, 2024
1 parent 66dbbb3 commit fc89216
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
*/
class Problem2285 extends LeetcodeProblem {

long maximumImportance(int n, int[][] roads) {
int[] deg = new int[n];
for (int[] r : roads) {
long maximumImportance(int _nbCities, int[][] _roads) {
int[] deg = new int[_nbCities];
for (int[] r : _roads) {
deg[r[0]]++;
deg[r[1]]++;
}
Arrays.sort(deg);
long ans = 0;
for (int i = 0; i < n; i++) {
ans += (long) (i + 1) * deg[i];
long result = 0;
for (int i = 0; i < _nbCities; i++) {
result += (long) (i + 1) * deg[i];
}
return ans;
return result;
}

}

0 comments on commit fc89216

Please sign in to comment.