FastPrepTime-Based Key-Value Store
Problems/Time-Based Key-Value Store

Time-Based Key-Value Store

Citadel logoCitadel● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel new grad onsite interview. The interviewer described it like this: set records a value for a key at a time, and get returns the closest earlier value for that key.

The report does not say what happens with duplicate writes or a missing result. Here, writes increase in time for each key, missing history returns an empty string, and calls are given as a list. Values are strings. The get in the report also takes an extra value argument. This version queries by key and time only.

Our version is about 90% the same as the reported question.

Process an in-memory store whose values have timestamps. A set call records a value for a key; a get call asks for that key at a particular time.

For this exercise, assume calls arrive as a finite list of string arrays:

  • ["set", key, value, timestamp] stores the value at that time.
  • ["get", key, timestamp] returns the value with the greatest stored timestamp less than or equal to the query time. Return an empty string if no such value exists.

Timestamps inside calls are decimal strings. Set timestamps are strictly increasing separately for each key; get times can be in any order. Return the get results in call order. A set call produces no output.

Function

timeStore(operations: String[][]) → String[]

Examples

Example 1

operations = [["set","foo","bar","1"],["get","foo","0"],["get","foo","1"],["set","foo","new","4"],["get","foo","3"],["get","foo","4"]]return = ["","bar","bar","new"]

The query at time 0 has no history. Time 1 returns bar; time 3 still returns bar; time 4 returns new.

Example 2

operations = [["get","missing","9"],["set","a","zero","0"],["set","b","other","0"],["get","b","0"],["get","a","100"]]return = ["","other","zero"]

The missing key returns an empty string. Keys a and b keep separate histories, including time 0.

Constraints

  • 1 <= operations.length <= 100000
  • Each operation is ["set", key, value, timestamp] or ["get", key, timestamp].
  • Keys and stored values have 1 to 20 lowercase English letters.
  • Timestamps are decimal integers from 0 to 1000000000.
  • Set timestamps for each key are strictly increasing.

More Citadel Onsite Interview questions

  • Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Removal PoolONSITE INTERVIEW · Seen Sep 2026
  • Centered K-by-K Submatrix SumsONSITE INTERVIEW · Seen Aug 2026
  • Search Suggestions with a Prefix TreeONSITE INTERVIEW · Seen Aug 2026
  • Traverse Interior Matrix Cells in Row-Major OrderONSITE INTERVIEW · Seen Aug 2026
  • 2048 Simulation and Board CodecONSITE INTERVIEW · Seen Jan 2026
  • Cancellable Priority Task QueueONSITE INTERVIEW · Seen Jan 2026
  • Dynamic Weighted SamplingONSITE INTERVIEW · Seen Jan 2026
  • Exchange Connection AlertsONSITE INTERVIEW · Seen Jan 2026

Similar questions at other companies

  • Top K Pins with Insert and QueryPinterest · PHONE SCREENPinterest interview questions
  • Snapshot Map with Sparse Version HistorySnorkel AI · PHONE SCREEN
  • Maintain a Consistent-Hashing RingCohesity · ONSITE INTERVIEW
  • Maintain a Consistent-Hashing RingApple · PHONE SCREENApple interview questions
  • Time-Based Key-Value StoreOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
  • Time-Based Key-Value StoreCockroach Labs · PHONE SCREEN · ONSITE INTERVIEW
  • Time Map with Sum and AverageConfluent · PHONE SCREENConfluent interview questions
  • Structured Log Stream with QueriesOpenAI · PHONE SCREENOpenAI interview questions
  • Time-Indexed Key-Value StoreTogether AI · ONSITE INTERVIEW
  • Globally Versioned Key-Value StoreLyft · ONSITE INTERVIEWLyft interview questions

Interview reports that mention this question

  • Citadel SWE Intern First-Round Questions: 20 Experiences

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public String[] timeStore(String[][] operations) {
      // write your code here
    }
}
Checking account…