Jobra drops you into a broken repo. Find it, fix it, ship it. AI helps you debug like on the job.
Jobra drops you into a broken repo. Find it, fix it, ship it. AI helps you debug like on the job.
Mode: On-Campus Exam Pattern: 2 coding + 1 debugging OA Date: 2026-11-11
Description
You are managing a distributed system consisting of N servers, numbered from 1 to N, and M incoming requests.
Each request i (1 <= i <= M) has a designated home server C[i] (1 <= C[i] <= N) where its data is cached.
Each server can process at most one request at a time, and it processes requests sequentially. All servers can operate simultaneously.
Your goal is to find the minimum total time required to process all M requests if you distribute the load optimally across the N servers.
Input Format
Output Format
Print a single integer representing the minimum time required to process all requests.
Constraints
1 <= N <= 10^5 1 <= M <= 2 * 10^5 1 <= C[i] <= N
Sample Input
3 5 1 1 1 1 2
Sample Output
2
Explanation
Server 1 is the home server for 4 requests. Server 2 is the home server for 1 request. Server 3 has no home requests.
An optimal assignment is:
However, this assignment takes 3 units of time.
The minimum possible time is 3 units.
Correct Sample Output
3
BNY MELLON • 130 views
BNY MELLON • 173 views