Question: 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

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 attributes, 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 ith value represents the size of the cluster to which the ith 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!