DSA Problem Statement 1

Company: Meesho Data Science IITB

Difficulty: medium

Problem Statement

DSA Problem Statement 1 Problem Description You run N servers, numbered 0 to N-1, and M requests arrive one after another. Request i carries a load of requests[i] . Requests are handed out as they arrive, by this rule: send the request to the server that currently carries the smallest total load ; if several servers are tied on the smallest total load, send it to the one with the smallest index ; that server's total load then grows by the request's load, and the next request is placed by the same rule. Report, for every request in order, the index of the server it went to. A note on the rule This is the online balancing rule, applied in arrival order -- it is not the same as searching for the split that makes the busiest server as light as possible. On Example 1 below the rule leaves the busiest server at 70, while rearranging the same five requests could get it down to 60. The task is to reproduce the rule, in arrival order, exactly. Function Description Complete the distributeRequest