Your question is LRU Cache for Audio Segments. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement an LRU (Least Recently Used) cache for audio segments. Design a class LRUCache with integer capacity and methods get(segment_id) and put(segment_id, data). get returns the stored segment data if present, otherwise -1. When inserting into a full cache, evict the least recently used segment. Both operations must run in O(1) average time.
def run_lru_cache(capacity, operations):