Design HashSet Problem
Design HashSet Problem — ExecCode Easy DSA Practice
Solve the Design HashSet 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 HashSet. Your task is to design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: - void add(key) Inserts the value key into the HashSet. - bool contains(key) Returns whether the value key exists in the HashSet or not. Return the required answer exactly as shown in the examples.
Examples
Input {"data": "3\nadd 1\ncontains 1\nremove 1\ncontains 1"}; Output true false. Input {"data": "5\nadd 1\nadd 2\ncontains 1\ncontains 3\nremove 1\ncontains 1"}; Output true false false. Input {"data": "10\nadd 5\nadd 10\ncontains 5\ncontains 10\nremove 5\ncontains 5\nadd 5\ncontains 5\nremove 10\ncontains 10"}; Output true true false true false
Constraints
0 <= key <= 10^6 At most 10^4 calls will be made to add, remove, and contains.
Practice Design HashSet free on ExecCode. Browse DSA problems, topic map, and placement guides.