LRU Cache Preparation

Hard Deque PRO
🔒 Login to Unlock

Problem Statement

Write a C program to simulate a basic Least Recently Used (LRU) queue/deque mechanism where items are accessed or updated.

Input Format

Capacity and sequence of page access keys.

Output Format

Print current cache contents from front to rear separated by spaces.

Constraints

1 <= capacity <= 10, 1 <= accesses <= 50

Sample Input

3 5
1 2 1 3 4

Sample Output

4 3 1

Explanation

Accessing a key brings it to the front of the deque; if the cache exceeds capacity, the rear element is evicted.

Starter Code

#include <stdio.h>
#include <stdlib.h>

int main() {
    int cap, accesses;
    if (scanf("%d %d", &cap, &accesses) == 2) {
        // Write your code here for LRU cache preparation deque simulation
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used