FastPrepSize-Weighted Random Server Picks
Problems/Size-Weighted Random Server Picks

Size-Weighted Random Server Picks

DocuSign logoDocuSign● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from January 2019 described this take-home task. Send each job to a random server, so that a bigger server gets proportionally more jobs. Its example had a size-4 server and a size-1 server, where the first should get about 80% of the jobs. A second report, from March 2019, called the same take-home a reworded version of the well-known random pick with weight problem.

The real program's output is random, so we cannot check it as is. Here the random numbers are given to you. The servers own consecutive blocks of numbers in the order given, and you return server indexes instead of names. There are 1 to 1000 servers of size 1 to 10^6, and 1 to 1000 draws. We wrote the examples. The January 2019 report also named comments, lint, tests, a README and a runnable script as things that counted. None of those are checked here.

Our version is about 70% the same as the reported questions.

A service sends each incoming job to one of its servers. sizes[i] is the size of server i. The server for a job is picked at random, and a server's chance must be proportional to its size. For example, with sizes [4, 1], server 0 should get about 4 out of every 5 jobs.

To make the answer checkable, the random numbers are already drawn for you. Let total be the sum of all sizes. The whole numbers 0 to total - 1 are split into blocks, one per server, in the order the servers are given:

  • server 0 owns the first sizes[0] numbers, 0 to sizes[0] - 1;
  • server 1 owns the next sizes[1] numbers;
  • and so on, so the last server owns the numbers up to total - 1.

draws[j] is the random number drawn for job j. Return an array whose j-th value is the index of the server that owns draws[j].

Function

pickServers(sizes: int[], draws: int[]) → int[]

Examples

Example 1

sizes = [4,1]draws = [0,4,1,2,3]return = [0,1,0,0,0]

Server 0 owns the numbers 0 to 3, and server 1 owns 4. So the draws 0, 4, 1, 2, 3 go to servers 0, 1, 0, 0, 0.

Server 0 is 4 times as big, and over many random draws it gets about 4 out of every 5 jobs.

Example 2

sizes = [2,5,3]draws = [9,0,2,6,7,1]return = [2,0,1,1,2,0]

The total is 10. Server 0 owns 0 to 1, server 1 owns 2 to 6, and server 2 owns 7 to 9.

So 9 goes to server 2, 0 to server 0, 2 and 6 to server 1, 7 to server 2, and 1 to server 0.

Example 3

sizes = [10]draws = [7,0]return = [0,0]

With one server, every job goes to server 0.

Constraints

  • 1 <= sizes.length <= 1000
  • 1 <= sizes[i] <= 10^6
  • 1 <= draws.length <= 1000
  • 0 <= draws[j] < total, where total is the sum of all sizes[i]

More DocuSign Online Assessment questions

  • Max Sum With No Two Adjacent PicksOA · Seen Apr 2026
  • Max Sum With No Two Adjacent Picks on a CircleOA · Seen Apr 2026
  • Beautiful Number OrderingsOA · Seen Feb 2026
  • Grid Path With the Most ClearanceOA · Seen May 2025
  • Vehicle Mixes for a Wheel TotalOA · Seen May 2025
  • Count Sales Rung Up at the Wrong PriceOA · Seen Feb 2021
  • Most Disjoint Intervals From Starts and DurationsOA · Seen Feb 2021
  • Fewest Fountains to Water the GardenOA · Seen Feb 2021
  • Lowest Start That Keeps Running Totals PositiveOA · Seen Feb 2021
  • Fewest Student Groups Within a Level GapOA · Seen Nov 2020

Similar questions at other companies

  • Choose ContainersIMC Trading · OAIMC Trading interview questions
  • Minimum Size Subarray SumMicrosoft · OAMicrosoft interview questions
  • Calculate Total Distance TravelledAmazon · OA
  • TikTok Metrics AnalysisTikTok · OATikTok interview questions
  • Load BalancingMathWorks · OAMathWorks interview questions
  • Largest Square Sub-Grid Within a Sum LimitC3.ai · OAC3.ai interview questions
  • Maximum Distinct Items Within a BudgetAdobe · OAAdobe interview questions
  • Calculating QuantilesIndeed · OAIndeed interview questions
  • Count Lamps Lighting Each PointCapital One · OACapital One interview questions
  • Maximum Non-Decreasing Array LengthVisa · OAVisa interview questions

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)
  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public int[] pickServers(int[] sizes, int[] draws) {
        // Write your code here.
    }
}
Checking account…