FastPrepDesign Hash Map
Problems/Design Hash Map

Design Hash Map

Apple logoApple● EasyFULLTIMENEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Apple phone screen for full-time and new grad roles. The report names the hash-map task. It does not give a way to send many operations at once, how to handle edge cases, or the input limits. We chose those. 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.

You get the arrays operations, keys, and values. Go through them from left to right. At index i, operations[i] says what to do:

  • "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. If the key is absent, it appends -1 instead. Call this the not-found value.
  • "remove" deletes keys[i] when present. Removing a missing key has no effect.

Return an integer array with the results of all get operations, in the order they ran.

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 get operations return 10 and -1, since the second asks for a key that was never stored. The next put changes the value of key 2 to 25, and the next get returns that value. Removing the key then makes the last get 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 the missing key 0 at the start has no effect. The first put stores the value 0, and the next get returns it. The second put replaces it with 7, which the next get returns. The key is then removed, so the last get returns the not-found value.

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 Apple Phone Screen questions

  • Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
  • Evaluate DivisionPHONE SCREEN · Seen Nov 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
  • Validate a BST with a Custom ComparisonPHONE SCREEN · Seen Nov 2026
  • Design a Food Rating SystemPHONE SCREEN · Seen Oct 2026
  • Days Until Poisoned Plants StabilizePHONE SCREEN · Seen Oct 2026
  • Capture Surrounded Regions with Union-FindPHONE SCREEN · Seen Oct 2026
  • Maintain a Consistent-Hashing RingPHONE SCREEN · Seen Oct 2026
  • Count Nodes in a ChainPHONE SCREEN · Seen Oct 2026
  • Run-Length DecodingPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • 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
  • Bounded Service Instance RegistryRevolut · PHONE SCREENRevolut interview questions
  • In-Memory Key-Value Store OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • In-Memory Fixed-Window Rate LimiterRippling · PHONE SCREENRippling interview questions
  • Design an Ordered StreamBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions

Apple interview experiences

  • Apple SWE Phone Screen: Subarray Products: 1 Experience
  • Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
  • Apple AI Coding and Related Interviews: 17 Experiences
  • Apple India SWE New Grad Interviews: 5 Experiences
  • Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
  • Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)
All Apple interview questionsSee Apple hiring insights
Saved
class Solution {
    public int[] runHashMap(String[] operations, int[] keys, int[] values) {
      // write your code here
    }

}
Checking account…