Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

In-Memory Store with TTL

Easy
CodingHash TablesData StructuresAlgorithms
Asked 1mo ago|
Ramp
Ramp
Asked 1 times

Problem

Implement an in-memory record store that supports setting and getting string keys. Each key stores a string value and may optionally have a TTL in seconds. Expired keys must behave as if they do not exist. Design a class with methods set(key, value, now, ttl=None), get(key, now), and delete(key, now).

Constraints

  • 1 <= number of operations <= 10^5
  • 0 <= now, ttl <= 10^9
  • Keys and values are non-empty strings
  • Calls may arrive with non-decreasing now values

Function Signature

def process_operations(operations):

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
def solve(rows):
    counts = {}
    for row in rows:
        ...
    return result
Sign up to unlock solutions
Ramp Software Engineer Interview QuestionsRamp Interview Questions
Next questions
AirbnbKey-Value Store With TTLMediumSocial FinanceKey-Value Store With TTLMediumCoinbaseTTL Support for In-Memory KeysHard
Python 3.10