Problem · Hash Table
Design HashMap
Learn this problemProblem statement
Process put, get, and remove operations without using a built-in hash-table implementation for the stored map. Get returns the value or -1 when absent. Return "null" for put and remove operations.
Function
runHashMap(operations: String[], keys: int[], values: int[]) → String[]Examples
Example 1
operations = ["put","put","get","get","put","get","remove","get"]keys = [1,2,1,3,2,2,2,2]values = [1,2,0,0,1,0,0,0]return = ["null","null","1","-1","null","1","null","-1"]The second put updates key 2, and remove makes its later get return -1.
Constraints
- All arrays have equal non-zero length.
0 <= key <= 10000000 <= value <= 1000000- There are at most
100000operations.