1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| type MyHashSet struct { data []bool }
func Constructor() MyHashSet { return MyHashSet{ data: make([]bool, 1000001), } }
func (this *MyHashSet) Add(key int) { this.data[key] = true }
func (this *MyHashSet) Remove(key int) { this.data[key] = false }
func (this *MyHashSet) Contains(key int) bool { return this.data[key] }
/** * Your MyHashSet object will be instantiated and called as such: * obj := Constructor(); * obj.Add(key); * obj.Remove(key); * param_3 := obj.Contains(key); */
|