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)) cache.put(0,1) print(cache.get(0)) if __name__ == "__main__": main()