Skip to main content
hard

Feature Flag Timeline Store

Feature Flag Timeline Store Track feature flag changes over time with time-travel queries. - set(ts, key, value): Set flag value at timestamp - get(ts, key): Get current value at timestamp (or "null" if not set) - getAt(ts, key): Get value at or before timestamp - delete(ts, key): Delete flag at timestamp (tombstone) - serialize()/deserialize(): Persist and restore history

Feature flags seem simple until you need to query what was enabled last Tuesday. This problem tests whether you can maintain a timeline with out-of-order updates and soft deletes—then serialize it for persistence. The trap is handling tombstones correctly in time-travel queries.

Examples

You write

FeatureFlagStore: set(timestamp: int, key: str, value: str), get(timestamp: int, key: str), get_at(timestamp: int, key: str), delete(timestamp: int, key: str), serialize(), deserialize(data: str)

  1. Example 1

    Input
    set(1,"darkMode",true), get(1,"darkMode")→true, get(1,"unknown")→null
    returns
    ["true", "null"]
  2. Example 2

    Input
    Multiple flags
    returns
    ["50", "blue"]

The pattern behind it

Design

I reach for it when

  • The statement describes a class with methods, not one function.
  • Each method needs to be fast, and the structure decides how fast.

Say this before you type. Say each method, the cost you want from it, and the structure that earns that cost.

All 27 Design problems

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.

1Basic Feature Flagsmedium
2Part 2
3Part 3
4Part 4

Each locked part opens in the editor once the part before it passes.