FastPrepWeighted Server Load Balancer with TTL
Problems/Weighted Server Load Balancer with TTL

Weighted Server Load Balancer with TTL

Stripe logoStripe● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe new-grad onsite interview. The source reports choosing the server with the smallest weight, alphabetical ties, TTL expiry, and maximum load. It leaves out how operations are written and several rules about the life of a server. Our version is about 87% the same as the reported question.

Assign tasks to available servers while tracking active weighted load.

  • Each server row is name,maxLoad.
  • Each task row is time,taskId,weight,ttl.

Process tasks in input order; task times are nondecreasing. Before each task, expire every earlier assignment whose end time startTime + ttl is at most the current task's time, and remove its weight from that server.

A server is eligible when its current load plus the task's weight does not exceed maxLoad. Choose the eligible server with the smallest current load, breaking ties by lexicographically smaller server name. An accepted task remains active until its end time.

Return one result per task as taskId:serverName. Return taskId:NONE when no server can accept the task.

Function

assignWeightedTasks(servers: String[], tasks: String[]) → String[]

Examples

Example 1

servers = ["a,5","b,4"]tasks = ["0,t1,3,5","1,t2,2,3","4,t3,4,2","5,t4,5,1"]return = ["t1:a","t2:b","t3:b","t4:a"]

The first task uses lexical tie-breaking. The second goes to the lighter server. Its TTL expires at time 4, making b available for t3; t1 expires before t4.

Example 2

servers = ["solo,3"]tasks = ["0,t1,3,5","0,t2,1,2","5,t3,3,1"]return = ["t1:solo","t2:NONE","t3:solo"]

The second task exceeds the remaining capacity. The first task expires at time 5, so the final task is accepted.

Example 3

servers = ["zeta,10","alpha,10"]tasks = ["2,x,1,3","2,y,1,3"]return = ["x:alpha","y:zeta"]

Both servers begin at load 0, so alpha wins the lexical tie. The next task then chooses the lighter zeta.

Constraints

  • 1 <= servers.length <= 1000; server names are unique.
  • 1 <= tasks.length <= 10000; task IDs are unique and times are nondecreasing.
  • Every maxLoad, task weight, and TTL is a positive integer at most 10^9.
  • Times and computed end times fit in signed 64-bit integers.
  • Rejected tasks do not consume load.
  • Tasks at the same time are processed in input order, and expirations at that time happen before assignment.

More Stripe Onsite Interview questions

  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Transaction Rule Expression EvaluatorONSITE INTERVIEW · Seen Oct 2026
  • Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
  • Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026

Similar questions at other companies

  • Cursor-Based Pagination Over Sorted LogsRoblox · ONSITE INTERVIEWRoblox interview questions
  • Meeting Rooms III: Most Booked RoomGoogle · ONSITE INTERVIEWGoogle interview questions
  • Shortest-Job-First Process SchedulingByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIIBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Meeting Rooms IISalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top K Largest Values from a StreamThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Generate Complete Inputs for a Supplied ClassifierGeneral Motors · ONSITE INTERVIEW

Interview reports that mention this question

  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe OA: What It Tests (2026)
  • Stripe SWE Onsite over Two Days: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] assignWeightedTasks(String[] servers, String[] tasks) {
      // write your code here
    }
}
Checking account…