Company: Target_13dec
Difficulty: medium
Cache Misses Problem Description Your task is to simulate a cache of a fixed size and calculate the total number of cache misses for a given sequence of page requests. The cache uses the Least Recently Used (LRU) replacement policy. This means: The cache is initially empty. When a page is requested, we first check if it's already in the cache. Cache Hit: If the page is in the cache, it's a "hit". The page is then marked as the most recently used page. Cache Miss: If the page is not in the cache, it's a "miss". If the cache is not full, the new page is added to the cache and marked as the most recently used. If the cache is full, the least recently used page is removed (evicted), and the new page is added and marked as the most recently used. You need to process the entire sequence of page requests and return the total count of cache misses. Input The input consists of three lines: The first line contains a positive integer N , representing the total number of page requests. The second