Company: Graviton_4nov
Difficulty: medium
Town Network Population Counting Problem Description A region has N towns, numbered 1 through N , joined by N - 1 roads so that the whole network forms a tree : between any two towns there is exactly one simple route. Town i has a population of population[i - 1] . Alice then receives Q queries. Each query gives two towns U and V and a number W , and asks how many towns **on the route from U to V ** have a population of at most W . Notes: Both endpoints U and V are part of the route and are counted. U and V may be the same town, in which case the route is that single town. The comparison is "at most": a town whose population is exactly W is counted. Function Description Complete the city_population() function provided in the editor. It takes five parameters: N: the number of towns population: the N populations, population[i - 1] belonging to town i road: the N - 1 roads, each a pair [u, v] Q: the number of queries cities: the Q queries, each a triple [u, v, w] It returns one count per q