Published:
Updated:

  • Reference
  • 체이닝 방식은 μ΄ν•΄ν•˜κΈ° λ„ˆλ¬΄ νž˜λ“€μ–΄μ„œ 일단 μ§€κΈˆμ€ 이 λ°©μ‹μœΌλ‘œ ν’€μ—ˆλ‹€,,


Solution

class MyHashMap:

    def __init__(self):
        self.map = [-1 for _ in range(1000001)]

    def put(self, key: int, value: int) -> None:
        self.map[key] = value

    def get(self, key: int) -> int:
        return self.map[key]

    def remove(self, key: int) -> None:
        self.map[key] = -1

# Your MyHashMap object will be instantiated and called as such:
# obj = MyHashMap()
# obj.put(key,value)
# param_2 = obj.get(key)
# obj.remove(key)

Leave a comment