Design Hashset
Running into some problems on this Leetcode exercise, I don't know what's wrong though
![No description](https://answer-overflow-discord-attachments.s3.us-east-1.amazonaws.com/1252254117514969128/image.png)
![No description](https://answer-overflow-discord-attachments.s3.us-east-1.amazonaws.com/1252254117955633276/image.png)
![No description](https://answer-overflow-discord-attachments.s3.us-east-1.amazonaws.com/1252254118425264210/image.png)
3 Replies
maybe input has values larger than 1000? 😄
Isolate the test inputs your set is failing for and it may become clearer. My guess is your hash function is bad (it is)
You're failing on only 6 tests, I'm betting that you have collisions where adding
a
overwrites b
another and a subsequent Contains(a)
thus yields false
Hash table
In computing, a hash table is a data structure that implements an associative array, also called a dictionary or simply map, which is an abstract data type that maps keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During ...