-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.py
More file actions
36 lines (30 loc) · 769 Bytes
/
solution.py
File metadata and controls
36 lines (30 loc) · 769 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
class MyHashSet(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.buckets = [0] * 1000000
def add(self, key):
"""
:type key: int
:rtype: void
"""
self.buckets[key] = 1
def remove(self, key):
"""
:type key: int
:rtype: void
"""
self.buckets[key] = 0
def contains(self, key):
"""
Returns true if this set did not already contain the specified element
:type key: int
:rtype: bool
"""
return self.buckets[key] == 1
# Your MyHashSet object will be instantiated and called as such:
# obj = MyHashSet()
# obj.add(key)
# obj.remove(key)
# param_3 = obj.contains(key)