Problem Solving/LeetCode

2023.10.04 Today's Challenge

fabichoi 2023. 10. 4. 23:45

https://leetcode.com/problems/design-hashmap/

 

LeetCode - The World's Leading Online Programming Learning Platform

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

매우 간단한 문제

class MyHashMap:
    def __init__(self):
        self.map = {}
    def put(self, key: int, value: int) -> None:
        self.map[key] = value
    def get(self, key: int) -> int:
        value = self.map.get(key)
        return value if value != None else -1
    def remove(self, key: int) -> None:
        self.map[key] = None
반응형