FastPrepDesign Hash Map
Problems/Design Hash Map

Design Hash Map

Goldman Sachs logoGoldman Sachs● EasyFULLTIMEOAPHONE SCREEN

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs online-assessment report names the well-known Design HashMap exercise. It does not give the interface, examples, constraints, or the assessment platform. This version uses a finite list of operations. Our version is about 95% the same as the reported question.

Implement a hash map that stores integer values under integer keys. Build the storage yourself without using a language's built-in hash table, map, or dictionary for the stored entries.

Process the arrays from left to right. At index i:

  • "put" stores values[i] under keys[i]. If the key already exists, replace its value.
  • "get" appends the value stored under keys[i] to the result, or appends -1 when the key is absent.
  • "remove" deletes keys[i] when present. Removing a missing key has no effect.

Return an integer array containing the results of all get operations in encounter order.

Function

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

Examples

Example 1

operations = ["put","put","get","get","put","get","remove","get"]keys = [1,2,1,3,2,2,2,2]values = [10,20,0,0,25,0,0,0]return = [10,-1,25,-1]

The first two queries return 10 and -1. Updating key 2 changes its value to 25, and removing it makes the final query return -1.

Example 2

operations = ["remove","put","get","put","get","remove","get"]keys = [0,0,0,0,0,0,0]values = [0,0,0,7,0,0,0]return = [0,7,-1]

Removing missing key 0 has no effect. The first insertion stores 0, the second insertion replaces it with 7, and the last query occurs after removal.

Constraints

  • 1 <= operations.length <= 100000.
  • operations.length == keys.length == values.length.
  • Every operation is "put", "get", or "remove".
  • 0 <= keys[i] <= 1000000.
  • For every put operation, 0 <= values[i] <= 1000000.

More Goldman Sachs Online Assessment questions

  • Maximum Ones After K OperationsOA · Seen Nov 2026
  • Palindrome CounterOA · Seen Oct 2026
  • Longest Palindromic SubsequenceOA · Seen Oct 2026
  • Count Redundant File BackupsOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Merge Overlapping IntervalsOA · Seen Sep 2026
  • Data ReorganizationOA · Seen Jul 2026
  • Alternating Parity PermutationsOA · Seen Jul 2026
  • Threshold AlertsOA · Seen Jul 2026
  • Find the Winner of an Array GameOA · Seen Jun 2026

Similar questions at other companies

  • Logger Rate LimiterGoogle · PHONE SCREENGoogle interview questions
  • Config Store with Priority OverridesMicrosoft · PHONE SCREENMicrosoft interview questions
  • ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Feature Flag EvaluationCVS Health · PHONE SCREEN
  • Student and Course EnrollmentWells Fargo · OAWells Fargo interview questions
  • Bounded Service Instance RegistryRevolut · PHONE SCREENRevolut interview questions
  • Smart Queue of Latest PricesCitadel · PHONE SCREENCitadel interview questions
  • In-Memory Key-Value Store OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Design Hash MapApple · PHONE SCREENApple interview questions
  • In-Memory Fixed-Window Rate LimiterRippling · PHONE SCREENRippling interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int[] runHashMap(String[] operations, int[] keys, int[] values) {
      // write your code here
    }

}
Checking account…