Design Hashset
Running into some problems on this Leetcode exercise, I don't know what's wrong though
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 ...