Level: Mid-Level
Round: Phone Screen · Type: Coding · Difficulty: 7/10 · Duration: 60 min · Interviewer: Unfriendly
Topics: System Design
Location: San Francisco Bay Area
Interview date: 2026-01-19
I had a technical phone screen. The design question was about implementing a sharding system.
The coding question was a new problem involving overlapping key ranges in a sharding system.
The problem involved a Shard class with id, start, and end attributes, and a Shards class with methods to add_shard, remove_shard, and rebalance. The goal of the rebalance method was to remove overlapping shards and fill in any gaps, while minimizing data movement. The limit variable indicates the maximum number of overlapping shards allowed at any point.
Here's the class definition:
` class Shard: id: str start: int end: int
class Shards: def init(self, limit: int): # Provided pass
def add_shard(self, shard: Shard):
# Provided
pass
def remove_shard(self, shard_id: str):
# Provided
pass
def rebalance(self):
# TODO
`
Example:
limit = 1 ('A', 0, 100) ('B', 80, 180) -> ('A', 0, 100) ('B', 101, 180)
I managed to get a working solution that passed the provided test cases, but I didn't have time to optimize it.