← revolut Interview Insights

revolut·Backend Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Revolut backend screen, one coding question about building a load balancer class from scratch. Pretty focused session, no fluff, they just wanted to see if you could handle the edge cases cleanly.

Questions Asked (1)

Q1

Design and implement a fixed-capacity load balancer that supports registering nodes, deregistering nodes, and randomly selecting an active node to route a request to. Make sure to handle cases like an empty pool, a full pool, and duplicate registrations.

Algorithms & Data StructuresSystem Design
Author's notes

My first instinct was to just use a list and call it a day, but the random pick with removal efficiency started nagging at me pretty quickly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify requirements and constraints, then design a data structure that supports O(1) registration, deregistration, and random selection. Use a hash map for node lookup and a dynamic array for O(1) random access, with swap-remove for efficient deletion. Discuss edge cases and concurrency considerations.

Pro tip: Mention that you would use a read-write lock to allow concurrent reads (random selection) while ensuring thread safety for writes (register/deregister), and discuss how to handle duplicate registrations by checking the hash map before insertion.

1. Clarify Requirements and Constraints

Ask about expected load, concurrency requirements, and whether nodes have unique identifiers. Confirm that random selection should be uniform over active nodes.

2. Design Data Structures

Propose using a hash map (dictionary) to store node ID to index mapping, and a dynamic array (list) to store active nodes. This enables O(1) random selection by index and O(1) registration/deregistration via swap-remove.

3. Implement Core Operations

Write pseudocode for register (check capacity and duplicates, add to array and map), deregister (swap with last element, update map, remove last), and pick random (generate random index, return node).

4. Handle Edge Cases

Address empty pool (return null or throw exception), full pool (reject registration), duplicate registration (ignore or update), and deregistering a non-existent node.

5. Discuss Concurrency and Scalability

Explain how to make the load balancer thread-safe using locks (e.g., read-write lock) and discuss potential bottlenecks and optimizations like sharding or lock-free structures.

Key Points to Mention

  • Use a hash map for O(1) lookup and a dynamic array for O(1) random access.
  • Swap-remove technique for O(1) deletion from the array.
  • Handle duplicate registrations by checking the hash map before insertion.
  • Return appropriate errors or null for empty pool and full pool.
  • Thread safety: use read-write locks to allow concurrent reads and exclusive writes.
  • Uniform random selection using a random number generator over the array indices.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.