705-design-hashset
DevGod needs to write a blog entry for this problem!
var MyHashSet = function() {
this.map={}
};
/**
* @param {number} key
* @return {void}
*/
MyHashSet.prototype.add = function(key) {
if(!this.map[key]){
this.map[key] = true
}
};
/**
* @param {number} key
* @return {void}
*/
MyHashSet.prototype.remove = function(key) {
if(this.map[key]){
delete this.map[key]
}
};
/**
* @param {number} key
* @return {boolean}
*/
MyHashSet.prototype.contains = function(key) {
if(this.map[key]){
return true
}else{
return false
}
};
/**
* Your MyHashSet object will be instantiated and called as such:
* var obj = new MyHashSet()
* obj.add(key)
* obj.remove(key)
* var param_3 = obj.contains(key)
*/