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

Time Based Key-Value Store

Zillow logoZillow● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Seen at Zillow in 2023 and 2024. In a 2023 thread about the Zillow phone screen, someone who had just moved to Zillow from another large tech company wrote that their interview questions were hash-map problems close to the well-known time based key-value store; another reply in the thread linked that task. That reply about the questions does not say which round asked them. A senior software engineer candidate for a big data role in India, interviewed in February 2024, had one interview with two questions the candidate called medium and listed a stack and a time map as what they were built on; we read the time map question as this task.

The reports do not describe Zillow's own version: the operations, what a lookup returns when nothing is stored at or before the asked time, whether stored timestamps always grow, limits, or how input reaches the code. Here we use the well-known version. A set stores a value under a key at a timestamp and keeps older values. A get returns the value stored under the key at the largest timestamp at or before the asked one, or an empty string when there is none. The timestamps of the sets strictly increase. Keys and values have 1 to 10 lowercase letters or digits, timestamps run from 1 to 10,000,000, and there are at most 10,000 operations. A function gets the operations as four arrays of the same length (operation names, keys, values, timestamps) and returns the answers of the get operations in order.

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

Build a time-based key-value store. For each key, it keeps every value stored under that key, together with the timestamp the value was stored at. The store starts empty.

You get four arrays of the same length: operations, keys, values and timestamps. Run the operations from left to right. At index i, operations[i] is one of these:

  • "set": store values[i] under the key keys[i] at the timestamp timestamps[i]. Values stored earlier under the same key are kept.
  • "get": look at the values stored under keys[i] at a timestamp less than or equal to timestamps[i]. Add the one with the largest such timestamp to the answer. If there is no such value, add the empty string "".

Return the answers of all "get" operations, in the order they ran.

Function

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

Examples

Example 1

operations = ["set","get","get","set","get","get"]keys = ["home","home","home","home","home","home"]values = ["400k","","","425k","",""]timestamps = [2,1,2,5,4,9]return = ["","400k","400k","425k"]

The key "home" gets "400k" at timestamp 2 and "425k" at timestamp 5. At timestamp 1 nothing is stored yet, so the first lookup returns "". At timestamps 2 and 4 the latest value is the one from timestamp 2, "400k". At timestamp 9 it is the one from timestamp 5, "425k".

Example 2

operations = ["set","set","set","get","get","get","get"]keys = ["door","roof","door","door","roof","door","roof"]values = ["red","blue","green","","","",""]timestamps = [1,3,6,5,5,6,2]return = ["red","blue","green",""]

Each key has its own history. At timestamp 5, "door" still has "red", because "green" arrives at timestamp 6, and "roof" has "blue". At timestamp 6, "door" has "green". At timestamp 2, "roof" has nothing yet, so the last lookup returns "".

Example 3

operations = ["get","set","get","get"]keys = ["x1","x1","y2","x1"]values = ["","v1","",""]timestamps = [10,10,10,10000000]return = ["","","v1"]

The first lookup runs before anything is stored, so it returns "". The key "y2" is never stored, so its lookup also returns "". The last lookup asks for "x1" at the largest timestamp and gets "v1", stored at timestamp 10.

Constraints

  • 1 <= operations.length <= 10000
  • keys.length == operations.length
  • values.length == operations.length
  • timestamps.length == operations.length
  • Each operations[i] is "set" or "get".
  • 1 <= keys[i].length <= 10
  • When operations[i] is "set", 1 <= values[i].length <= 10.
  • When operations[i] is "get", values[i] is "" and is not used.
  • keys[i] and values[i] contain only lowercase English letters and digits.
  • 1 <= timestamps[i] <= 10000000
  • The timestamps of the "set" operations are strictly increasing, in the order the operations run.

More Zillow Phone Screen questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Jump GamePHONE SCREEN · Seen Dec 2022
  • Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
  • Employee Free TimePHONE SCREEN · Seen Oct 2022
  • First Unique Character in a StringPHONE SCREEN · Seen Oct 2022
  • K-th Smallest Number in a StreamPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Frequency-Weighted Next-Word SamplingGoogle · PHONE SCREENGoogle interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Consistent-Hash Packet RouterAmazon · PHONE SCREEN
  • Snapshot Map with Sparse Version HistorySnorkel AI · PHONE SCREEN
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Design a Food Rating SystemApple · 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
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public String[] runTimeMap(String[] operations, String[] keys, String[] values, int[] timestamps) {
        // Write your code here.
    }
}
Checking account…