forked from super30admin/Design-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem2.py
More file actions
39 lines (30 loc) · 767 Bytes
/
Problem2.py
File metadata and controls
39 lines (30 loc) · 767 Bytes
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
36
37
38
39
# Brute Force Approach
class MyHashMap(object):
def __init__(self):
self.hashmap= [-1 for _ in range(1000001)]
def put(self, key, value):
"""
:type key: int
:type value: int
:rtype: None
"""
self.hashmap[key]= value
def get(self, key):
"""
:type key: int
:rtype: int
"""
return self.hashmap[key]
def remove(self, key):
"""
:type key: int
:rtype: None
"""
self.hashmap[key]= -1
# Your MyHashMap object will be instantiated and called as such:
# obj = MyHashMap()
# key=1
# value= 2
# obj.put(key,value)
# param_2 = obj.get(key)
# obj.remove(key)