init: initial commit

This commit is contained in:
mau
2026-06-12 20:35:24 +02:00
parent 6232adcca9
commit 3bda02f563
5 changed files with 61 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
class LRUCache:
def __init__(self, capacity: int):
self.capacity = capacity
self.slots = []
def get(self, key: int) -> int:
if key <= len(self.slots) -1:
return self.slots[key]
return -1
def put(self, key: int, value: int) -> None:
if self.capacity > len(self.slots):
self.slots.append(value)
else:
self.slots[len(self.slots) - 1] = value
def main():
cache = LRUCache(2)
print(cache.get(1))
print(cache.get(0))
if __name__ == "__main__":
main()