Graph Challenge

Company: Jupiter money

Difficulty: medium

Problem Statement

Graph Challenge Problem Description A region has several cities joined by two-way roads. The road network is a tree: every pair of cities is connected by exactly one route, and there are no cycles. Each city is labelled by a distinct positive integer, and that label is also the population of the city. Suppose every person in the region travels to one chosen city c . Each road that ends at c carries the people who live on the far side of that road, that is, the total population of all the cities that can only reach c through that road. The people of c itself stay home and are not counted. The maximum traffic of c is the largest load among all the roads that end at c . The network is given as an array of strings strArr , one string per city, in the form city:[n1,n2,...,nk] , where city is the city's label and n1 ... nk are the labels of all the cities directly connected to it by a road. Every road appears in the lists of both of its end cities. Return a single string listing the maximum