Code Room
CodingMediumcod-g1051
Subject Storage quotaLevel Mid–Senior~25 minCommon in Storage & CDN interviewsIndustries Software development, Technology

Question

Track space usage under a byte quota. A store maps string keys to blob sizes (bytes) and enforces a fixed `quota` on total bytes used. Process operations: ["write", key, size] attempts to store/overwrite key with a blob of `size` bytes — it succeeds only if total used bytes AFTER the write would be <= quota (when overwriting an existing key, the old size is released first for this check); on failure the write is rejected and the key keeps its previous value (or stays absent). ["delete", key] removes key and frees its bytes (no-op if absent). Return a list of booleans, one per "write" op in order, indicating whether each write succeeded. size >= 0; <= 10^5 ops.

Implement
quota_writes(quota: int, ops: list[list]) → list[bool]
Examples
in[10,[["write","a",6],["write","b",6],["write","b",4]]]out[true,false,true]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.