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 30 31 32 33 34 35
| const N = 1000001
type MyHashMap struct { data []int }
func Constructor() MyHashMap { data := make([]int, N) for i := 0; i < N; i++ { data[i] = -1 } return MyHashMap{ data, } }
func (this *MyHashMap) Put(key int, value int) { this.data[key] = value }
func (this *MyHashMap) Get(key int) int { return this.data[key] }
func (this *MyHashMap) Remove(key int) { this.data[key] = -1 }
/** * Your MyHashMap object will be instantiated and called as such: * obj := Constructor(); * obj.Put(key,value); * param_2 := obj.Get(key); * obj.Remove(key); */
|