Spring Hire Sale
Limited Time Deal: Unlock all premium questions for over 30% off
$10.42$7.08
08
:
04
:
54
:
39
Back to Dashboard
Shard Rebalancer
Hard
You are implementing a shard management system for a distributed key-value store. Each shard is identified by a string and covers a contiguous range of integer keys, represented as "<id>:<start>:<end>".
To balance load, the system enforces a coverage limit: no key may be covered by more than limit active shards simultaneously. Implement rebalance(limit, shards) which resolves overlaps and fills gaps according to these deterministic rules:
...