PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Revolut

Implement a random fixed-size load balancer

Last updated: Jun 1, 2026

Quick Overview

This question evaluates understanding of randomized selection, efficient in-memory data structures, and API/state management for a fixed-capacity load balancer that must support addNode, removeNode, and uniform random routing while handling duplicates, removals, and empty-state behavior.

  • medium
  • Revolut
  • Coding & Algorithms
  • Software Engineer

Implement a random fixed-size load balancer

Company: Revolut

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem: Build a simple load balancer Implement a minimal in-memory load balancer that routes each incoming request to **one backend node chosen uniformly at random**. ### Requirements - The load balancer maintains a **set of backend nodes** (e.g., strings or IDs). - The number of nodes is bounded by a fixed maximum capacity `K`. - Support these operations: 1. `addNode(nodeId)` - Adds a node if it is not already present. - If the load balancer is at capacity `K`, define and document what happens (e.g., reject the add / throw). 2. `removeNode(nodeId)` - Removes the node if present; otherwise no-op. 3. `route()` (or `getNodeForRequest()`) - Returns a node chosen **uniformly at random** from the currently active nodes. - If there are **no nodes**, define and document what happens (e.g., return null / throw). ### Constraints / Edge cases to handle - Adding duplicates. - Removing a non-existent node. - Routing when empty. - Keeping `route()` efficient (ideally O(1)). ### Deliverable Describe the data structures and implement the API (language-agnostic or Java-style).

Quick Answer: This question evaluates understanding of randomized selection, efficient in-memory data structures, and API/state management for a fixed-capacity load balancer that must support addNode, removeNode, and uniform random routing while handling duplicates, removals, and empty-state behavior.

Related Interview Questions

  • Implement a thread-safe money transfer - Revolut (medium)
Revolut logo
Revolut
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
13
0

Problem: Build a simple load balancer

Implement a minimal in-memory load balancer that routes each incoming request to one backend node chosen uniformly at random.

Requirements

  • The load balancer maintains a set of backend nodes (e.g., strings or IDs).
  • The number of nodes is bounded by a fixed maximum capacity K .
  • Support these operations:
    1. addNode(nodeId)
      • Adds a node if it is not already present.
      • If the load balancer is at capacity K , define and document what happens (e.g., reject the add / throw).
    2. removeNode(nodeId)
      • Removes the node if present; otherwise no-op.
    3. route() (or getNodeForRequest() )
      • Returns a node chosen uniformly at random from the currently active nodes.
      • If there are no nodes , define and document what happens (e.g., return null / throw).

Constraints / Edge cases to handle

  • Adding duplicates.
  • Removing a non-existent node.
  • Routing when empty.
  • Keeping route() efficient (ideally O(1)).

Deliverable

Describe the data structures and implement the API (language-agnostic or Java-style).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Revolut•More Software Engineer•Revolut Software Engineer•Revolut Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.