Loading...

The Load Balancer

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid, senior

Problem

Implement a LoadBalancer class that maintains a list of server IDs. It should support add_server(server_id), remove_server(server_id), and get_server() which returns the next server using round-robin rotation. If no servers are available, raise an exception.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.