Parcel Attribute Store with TTL
Updated
Problem statement
Process timestamped operations on parcels. Each parcel stores named attributes, and each attribute value is a string. Each attribute has its own expiration time, set by its time to live (TTL). An operation is given as an array of strings.
["SET", timestamp, parcel, name, value, ttl]overwrites the attribute and returns"OK". A TTL of zero means it never expires.- An attribute is live if it has been set and has not expired.
["GET", timestamp, parcel, name]returns the live value, or an empty string if there is none. ["UPDATE_IF_MATCH", timestamp, parcel, name, expected, value, ttl]updates a live attribute only when its current value equalsexpected. It returns"true"on success and"false"otherwise.["LIST", timestamp, parcel]returns the parcel's live attributes asname(value), sorted by name and joined with", ".["LIST_PREFIX", timestamp, parcel, prefix]returns the same list, but only for names that start withprefix.
Say an attribute is set at time t with a positive TTL. It is missing at time t + ttl and at every later time, unless it is set again. Return one string per operation, in input order.
Function
processParcelAttributes(operations: String[][]) → String[]Examples
Example 1
operations = [["SET","1","p1","color","red","5"],["SET","2","p1","carrier","air","0"],["LIST","3","p1"],["GET","6","p1","color"],["LIST_PREFIX","6","p1","car"]]return = ["OK","OK","carrier(air), color(red)","","carrier(air)"]Both SET operations return OK. The color is set at time one with a TTL of five, so it expires exactly at time six. The carrier has a zero TTL, so it never expires. At time three both are live, so LIST returns carrier(air), color(red), sorted by name. At time six the color has expired, so GET returns an empty string. The carrier remains, so LIST_PREFIX with car returns carrier(air).
Example 2
operations = [["SET","4","p","zone","west","0"],["UPDATE_IF_MATCH","5","p","zone","east","north","0"],["UPDATE_IF_MATCH","6","p","zone","west","north","3"],["GET","9","p","zone"]]return = ["OK","false","true",""]SET stores west as the zone and returns OK. The first update expects east, but the value is west, so it fails and returns false. The second update expects west, so it succeeds and returns true. It sets the zone to north at time six with a TTL of three, so the replacement expires at time nine. So GET at time nine returns an empty string.
Constraints
1 <= operations.length <= 100000- Timestamps are nondecreasing integers between
0and1000000000. - Parcel IDs, attribute names, prefixes, and values contain at most
80visible ASCII characters; names contain no parentheses or commas. 0 <= ttl <= 1000000000.
More Airbnb Online Assessment questions
- In-Memory File SystemOA · Seen Nov 2026
- Task Management SystemOA · Seen Nov 2026
- Recipe Management SystemOA · Seen Nov 2026
- Progressive Banking SystemOA · Seen Nov 2026
- Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
- Parcel Event TrackingOA · Seen Oct 2026
- Median Home Price by CityOA · Seen Sep 2026
- Worker Management (Promotion Track), Part 4: Full-Shift Double PayOA · Seen Sep 2026
- Worker Management (Promotion Track), Part 3: Promotions and SalaryOA · Seen Sep 2026
- Workspace Credit LedgerOA · Seen Aug 2026
Similar questions at other companies
- Power Cell BankOptiver · OAOptiver interview questions
- Four-Level Banking System with Scheduled PaymentsZipRecruiter · OAZipRecruiter interview questions
- Task Management SystemCoinbase · OACoinbase interview questions
- Task Management SystemAnthropic · OAAnthropic interview questions
- Progressive Parcel Tracking OperationsKlaviyo · OAKlaviyo interview questions
- Versioned Recipe SystemThe Trade Desk · OA
- Recipe Management SystemRamp · OARamp interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Process Banking OperationsVercel · OA
- HTTP Request RedirectionAmazon · OA