You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// e.g. the 0th city's count will be stored at index zero in the array
6
7
for(let[cityTo,cityFrom]ofroads){
7
8
connectionCount[cityTo]++
8
9
connectionCount[cityFrom]++
9
10
}
10
-
11
+
11
12
letcityToConnectionCount=[]
12
13
for(letcity=0;city<n;city++){
13
14
cityToConnectionCount.push([city,connectionCount[city]])// Store the [city, numberOfConnections]
14
15
}
15
-
16
+
16
17
// Created new array(sortedCities) for readability
17
-
constsortedCities=cityToConnectionCount.sort((a,b)=>b[1]-a[1])// sort by number of connections, the city with the greatest number of connections should be
18
+
constsortedCities=cityToConnectionCount.sort((a,b)=>b[1]-a[1])// sort by number of connections, the city with the greatest number of connections should be
0 commit comments