Company: UKG
Difficulty: medium
Neural Task Allocation A batch of n jobs is described by an array task, where task[i] records that job's category. A distributed inference cluster has m identical worker nodes, and for the cluster to run efficiently every node must end up handling exactly the same number of jobs. In addition, no worker node may be given two jobs from the same category. Choose an assignment of jobs to nodes that respects both rules and completes as many jobs as possible; return that maximum count. Note: every node must receive an identical number of jobs. Function Description Complete the function findMaximumTasks with the following parameters: int task[n] : the type of each task int m : the number of nodes in the neural network system Returns int : the maximum number of tasks that can be completed by distributing tasks optimally Constraints 1 ≤ n ≤ 3 × 10⁵ 1 ≤ task[i] ≤ 10⁹ 1 ≤ m ≤ 10⁹ Example Given: n = 7 task = [1, 2, 2, 1, 3, 1, 3] m = 2 One way to reach the best outcome is: Node 1 takes on the 1 st