0
点赞
收藏
分享

微信扫一扫

leetcode 705. 设计哈希集合


看了范围不是很大使用了数组,不是正规解法

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];
}
};

leetcode 705. 设计哈希集合_哈希

有时间学习正规的解法吧:(拖延症)
​​​https://leetcode-cn.com/problems/design-hashset/comments/​​


举报

相关推荐

0 条评论