Company: Thoughtspot
Difficulty: medium
3. Server Clusters Given an array serverProp representing the properties of n servers. In a pool of servers, two servers located at indexes i and j are considered connected if the greatest common divisor of their properties, serverProp[i] and serverProp[j] , is greater than 1. These connected servers, whether connected directly or indirectly through others, form server clusters in the network. Determine the size of the cluster to which each server belongs. Report an array of integers where the i th value represents the size of the cluster to which the i th server belongs. Function Description Complete the function getClusterSizes in the editor below. getClusterSizes has the following parameters: serverProp[n] : the properties of servers that determine server connectivity Returns int[n] : the total size of the cluster to which each server belongs Constraints 1 ≤ n ≤ 10 5 1 ≤ serverProp[i] ≤ 10 5 Example 1 Input: n = 3 serverProp = [1, 2, 4] Output: [1, 2, 2] Based on the given server pr