看了范围不是很大使用了数组,不是正规解法
class MyHashSet {
public:
/** Initialize your data structure here. */
bool * hx;
MyHashSet() {
hx = new bool [1000001];
memset( hx,0,1000001 );
}
void add(int key) {
hx[key] = true;
}
void remove(int key) {
hx[key] = false;
}
/** Returns true if this set contains the specified element */
bool contains(int key) {
return hx[key];
}
};
有时间学习正规的解法吧:(拖延症)
https://leetcode-cn.com/problems/design-hashset/comments/