Company: LinkedIn_SDE intern_On-campus_6july
Difficulty: medium
Hackerland Prime Index Allocation Problem Description Hackerland has n cities, numbered from 1 to n , connected by n - 1 roads so that the road network forms a tree (it is connected and has no cycle). The i -th road directly connects the cities edge_from[i] and edge_to[i] . Roads have no direction. The mathematicians of Hackerland want to give every city an index. An allocation of indices is valid when both of these conditions hold: The index of every city is a prime number between 2 and 100 , both inclusive. For every road, the sum of the indices of the two cities it connects is NOT a prime number. The same prime may be used for any number of cities. (inferred -- the source text calls the index "unique", but its own first example counts all 25 x 25 = 625 ordered pairs, including pairs such as [2, 2] with a repeated prime, so repeated primes are allowed.) Two allocations are different when at least one city gets a different index. Find the number of valid allocations. Since the number