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

Time-Based Key-Value Store

Snowflake logoSnowflake● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the time-based key-value exercise. Looking up a value by timestamp is the main part of it. We chose a finite list of operations, the order of writes for each key, the result strings, the limits and the examples. Our version is about 90% the same as the reported question. This exercise comes from a collection of interview-prep questions, not from one dated interview.

Start with an empty store of string keys and values. Process timestamped writes and reads from first to last. The entries at index i in the four input arrays describe one operation.

  • operations[i] == "set": store values[i] under keys[i] at timestamps[i]. Add the string "null" to the result.
  • operations[i] == "get": look at the earlier writes for that key. Return the value from the write with the latest timestamp that is at most timestamps[i]. Add that value to the result, or the empty string if no such version exists. The corresponding values[i] is empty and is ignored.

Process operations in array order and return one string per operation. A read cannot see writes from later operations. For each individual key, timestamps of set operations strictly increase; read timestamps may arrive in any order, and timestamps need not increase across different keys.

Function

runTimeMap(operations: String[], keys: String[], values: String[], timestamps: int[]) → String[]

Examples

Example 1

operations = ["set","get","set","get","get"]keys = ["item","item","item","item","item"]values = ["old","","new","",""]timestamps = [2,1,7,6,7]return = ["null","","null","old","new"]

The query at 1 precedes the first version. At 6 the old version is latest; the query at 7 includes the new version.

Example 2

operations = ["set","set","get","get","get","get"]keys = ["alpha","beta","alpha","alpha","beta","beta"]values = ["red","blue","","","",""]timestamps = [10,3,9,10,3,2]return = ["null","null","","red","blue",""]

Histories are separate by key. Set timestamps need not increase across different keys.

Example 3

operations = ["get","set","get","set","get","get"]keys = ["k","k","k","k","k","k"]values = ["","old","","new","",""]timestamps = [100,5,100,10,6,10]return = ["","null","old","null","old","new"]

Queries see only earlier operations, even when a query timestamp is greater than a later write timestamp.

Constraints

  • 1 <= operations.length <= 2000, and all four arrays have equal length.
  • Each operation is exactly "set" or "get".
  • Every key contains 1 to 32 case-sensitive English letters or decimal digits.
  • A set value contains 1 to 32 case-sensitive English letters or decimal digits. A get value is the empty string.
  • 1 <= timestamps[i] <= 10^9.
  • Set timestamps are strictly increasing separately for each key.

More Snowflake Phone Screen questions

  • Minimum StackPHONE SCREEN · Seen Nov 2026
  • Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
  • Merge Two Binary TreesPHONE SCREEN · Seen Nov 2026
  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
  • Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
  • Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Consistent-Hash Packet RouterAmazon · PHONE SCREEN
  • Snapshot Map with Sparse Version HistorySnorkel AI · PHONE SCREEN
  • 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-Based Key-Value StoreVerkada · PHONE SCREENVerkada interview questions
  • Interview Slot BookingTrueFoundry · PHONE SCREEN
  • Frequency-Weighted Next-Word SamplingGoogle · PHONE SCREENGoogle interview questions
  • Time-Based Key-Value Map With Floor and Ceiling QueriesCharacter.AI · PHONE SCREEN

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public String[] runTimeMap(String[] operations, String[] keys, String[] values, int[] timestamps) {
        // Write your code here.
    }
}
Checking account…