noob_14's blog

By noob_14, history, 2 months ago, In English

A planned state consists of cities connected by bidirectional roads of different types. For example, one road may be an expressway and another a boulevard. Each road can be described by three integers that represent the two connected cities and the road type. To reduce maintenance, some roads may be demolished. All others will be upgraded. If each city is to remain connected to all currently connected cities by the same type of road, determine the minimum number of roads of each type that will be upgraded.


numCities = 4 numRoads = 5 numTypes = 2 fromCity = [3,0,0,2,1] toCity =[2,3,2,1,3] roadType = [1,0,0,1,1]

Return an array with the count for road type 0 at the 0th index, type 1 at the 1st index and so on.

In this case Ans = [2,2]

can anyone help me how to solve this problem ? Thanks in advance :))

  • Vote: I like it
  • +2
  • Vote: I do not like it