Weighted Random City Selection by Population
Given an array of city names cities and corresponding positive integer populations populations, implement weighted random city selection.
The probability of selecting cities[i] must be:
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
