A Sorted Key-Value Store with Range Queries

medium
Unit 22 · Bisect0/0 to milestone

Implement SortedStore that keeps keys sorted (using bisect, not re-sorting) and supports:

  • put(key, value) (overwrites existing), get(key, default=None), delete(key) (no error if missing)
  • range(lo, hi): list of (key, value) with lo <= key < hi, in key order
  • floor(key): the largest stored key <= key, or None; ceiling(key): the smallest >= key, or None
  • __len__
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
A Sorted Key-Value Store with Range Queries · TechGradify