Ctrl K
Backend · Junior · Coding

Write a simple in-memory key-value store with a time to live for entries. You need two methods: set takes a key, a value and a time to live in seconds, and get takes a key and returns the value, or an empty result if the key doesn't exist or its time to live has already expired.

~15 min by voice

How to approach it

This checks whether you can pick the right data model from a simple requirement: store the absolute expiration moment and check it lazily on read. Interviewers also look at care with edge cases: a missing key, expiry, a repeated write, an odd TTL.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~15 min