Programming Exercises

Build a component that simulates a simple LRU (Least Recently Used) Cache and displays the cache contents after each operation.

Hard

Problem Statement

Build a component that simulates a simple LRU (Least Recently Used) Cache and displays the cache contents after each operation.

Sample Input

[1, 2, 3, 4, 2, 5]

Sample Output

Cache Contents: [3, 5, 2]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React, { useState } from "react"; const LRUCache = () => { return ( <div> {/* Display the cache contents */} </div> ); }; export default LRUCache;
Log in or sign up to run or submit your code.Log inSign up
Input
[1, 2, 3, 4, 2, 5]
Expected Output
Cache Contents: [3, 5, 2]