Company: Meesho Data Science IITB
Difficulty: medium
DSA Problem Statement 1 Problem Description You are given N servers (numbered from 0 to N-1) and M requests. Each request has an associated load, represented by the array requests[] , where requests[i] denotes the load of the i-th request. Your task is to assign each request to one of the N servers such that the overall load is distributed as evenly as possible — in other words, the most loaded (busiest) server should have the minimum possible total load. Return an array ans[] of length M, where ans[i] is the index of the server to which the i-th request is finally assigned. Examples Example 1: Input: N = 3 requests = [10, 20, 30, 40, 50] Output: [0, 1, 2, 0, 1] Explanation: The goal is to minimize the load of the most busy server after all assignments. If multiple valid distributions exist, any one of them can be returned. One possible optimal assignment process: Request 0 (load 10) → Server 0 Request 1 (load 20) → Server 1 Request 2 (load 30) → Server 2 Request 3 (load 40) → Server 0