Some checks failed
Deploy to birb co. production / deploy (push) Failing after 6s
21 lines
461 B
Python
21 lines
461 B
Python
class Dictionary:
|
|
backing: "list" = [None] * 26
|
|
|
|
def hash(self, key: str):
|
|
return ord(key) - 97
|
|
|
|
def get(self, key: str):
|
|
index = self.hash(key)
|
|
return self.backing[index]
|
|
|
|
def set(self, key: str, value):
|
|
index = self.hash(key)
|
|
self.backing[index] = value
|
|
|
|
sample_dict = Dictionary()
|
|
sample_dict.set("h", "hello")
|
|
sample_dict.set("i", "hello")
|
|
print(sample_dict.get("j"))
|
|
print(sample_dict.get("i"))
|
|
|