Design HashMap Problem
Design HashMap Problem — ExecCode Easy DSA Practice
Solve the Design HashMap problem on ExecCode. Free online easy DSA practice in Hashing. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given the input needed to solve Design HashMap. Your task is to design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: - MyHashMap() initializes the object with an empty map. - void put(int key, int value) inserts a (key, value) pair into the HashMap. Return the required answer exactly as shown in the examples.
Examples
Input {"data": "5\nput 1 1\nput 2 2\nget 1\nget 3\nput 2 1\nget 2\nremove 2\nget 2"}; Output 1 -1 1 -1. Input {"data": "3\nput 1 10\nget 1\nremove 1\nget 1"}; Output 10 -1. Input {"data": "4\nput 1 1\nput 1 2\nget 1\nremove 1\nget 1"}; Output 2 -1
Constraints
0 <= key, value <= 10^6 At most 10^4 calls will be made to put, get, and remove.
Practice Design HashMap free on ExecCode. Browse DSA problems, topic map, and placement guides.