i'm mansi, cs undergraduate at banasthali vidyapith. lately I’m into low level stuff (learning rust) and building things with <code/> sometimes it works, sometimes it doesn’t.
mail- mail me
portfolio- portfolio
linkedin- linkedin
my cute lil' hashmap <3 (O(1) always)
class HashMap:
def __init__(self):
self.bucket = []
for i in range(7):
self.bucket.append([])
print("hashmap initialized cause built in is too basic")
# i genuinely love HashMaps <3
def put(self, key, value):
index = hash(key) % len(self.bucket)
for i, (k, v) in enumerate(self.bucket[index]):
if k == key:
self.bucket[index][i][1] = value
print(f" Updated: '{key}' now maps to '{value}'")
return
self.bucket[index].append([key, value])
print(f" Added: '{key}' → '{value}' 'cause i love mapping stuff <3 ")
def get(self, key):
index = hash(key) % len(self.bucket)
for k, v in self.bucket[index]:
if k == key:
print(f"Found: '{key}' → '{v}' just like finding answers in life")
return v
print(f"Oops: '{key}' not found. doesn’t exist in the map")
return None
def remove(self, key):
index = hash(key) % len(self.bucket)
before = len(self.bucket[index])
self.bucket[index] = [pair for pair in self.bucket[index] if pair[0] != key]
after = len(self.bucket[index])
if before != after:
print(f"Removed: '{key}' (if it existed)")
else:
print(f"'{key}' wasn’t even here. nothing to remove")


