FastPrepIn-Memory Key-Value Store Serialization
Problems/In-Memory Key-Value Store Serialization

In-Memory Key-Value Store Serialization

OpenAI logoOpenAI● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an OpenAI phone screen for a full-time role. The interview report asks for serialization and deserialization of an in-memory key-value store. It says that helpers for converting 32-bit integers are supplied. It does not say the map operations, the byte framing, the order, the command results, a finite way to run it, the examples, or the limits. The rules we chose below fill in those gaps with a fixed outcome.

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

You are given a list of operations. Run them in order on an in-memory store that maps string keys to string values. The store starts empty.

  • ["PUT", key, value] saves the value under the key and returns "OK". If the key already has a value, the new one replaces it.
  • ["GET", key] returns "VALUE:" + value if the key is in the store. Otherwise it returns "NOT_FOUND".
  • ["SERIALIZE"] returns a snapshot of the whole store as one string. The format below fixes it exactly, so the same store always gives the same snapshot.
  • ["DESERIALIZE", snapshot] throws away the whole current store, loads the store written in the snapshot, and returns "OK".

To build a snapshot, write every key and every value as its length followed right away by its characters. The length is the number of characters, written as a 32-bit number in eight uppercase hexadecimal digits. Write each key followed by its value, and list the pairs sorted by key in lexicographic order. An empty store gives the empty string. Every snapshot passed to DESERIALIZE is valid and uses this format.

Return one result for each operation.

Function

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

Examples

Example 1

operations = [["PUT","b","two"],["PUT","a","one"],["SERIALIZE"],["GET","a"]]return = ["OK","OK","00000001a00000003one00000001b00000003two","VALUE:one"]

The two PUT operations each return "OK". The snapshot lists key a before key b, even though b was added first. Every key and value starts with its length in eight hexadecimal digits, then its characters. Last, GET finds a and returns "VALUE:one".

Example 2

operations = [["PUT","x:y",""],["SERIALIZE"],["DESERIALIZE","00000001a00000003one"],["GET","x:y"],["GET","a"]]return = ["OK","00000003x:y00000000","OK","NOT_FOUND","VALUE:one"]

The key x:y holds an empty value. The snapshot still reads correctly. The colon is just part of the key, because the length says where the key ends. The empty value is written as its length with no characters after it. Next, DESERIALIZE replaces the whole store with the snapshot's only pair, a mapped to one. So GET on x:y returns "NOT_FOUND", and GET on a returns "VALUE:one".

Constraints

  • 1 <= operations.length <= 2000.
  • Keys are non-empty printable ASCII strings of length at most 100; values are printable ASCII strings of length at most 1000.
  • Every command has the exact fields described above.
  • Every supplied snapshot is valid, and the total input size is at most 200000 characters.

More OpenAI Phone Screen questions

  • Secret Number Search with One-Call-Delayed FeedbackPHONE SCREEN · Seen Nov 2026
  • Determine the Winner of Three-Card HandsPHONE SCREEN · Seen Nov 2026
  • Grid Infection with Recovery After D DaysPHONE SCREEN · Seen Nov 2026
  • Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Light Source Hits: Sample, Compare, and FitPHONE SCREEN · Seen Nov 2026
  • Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adaptive Calibration ErrorPHONE SCREEN · Seen Nov 2026
  • Elevator Scheduling SimulationPHONE SCREEN · Seen Nov 2026
  • Evaluate Noisy AnnotatorsPHONE SCREEN · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Spreadsheet With Dependent CellsCharacter.AI · PHONE SCREEN
  • JSON Schema Object ValidatorDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Spreadsheet Formula DependenciesAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Video Cache Hit Rates from a CSV LogTubi · PHONE SCREEN
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions

OpenAI interview experiences

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public String[] processSerializedStore(String[][] operations) {
        // Write your code here.
    }
}
Checking account…