LRU Cache Simulator

JavaScript Hard 4 views
Back to Questions

Problem Description

Implement LRU cache of capacity C. Commands: GET key, PUT key value. GET prints value or -1. PUT updates cache.

Input Format

First line: C q. Next q lines commands.

Output Format

Output for each GET.

Sample Test Case

Input:
2 7 PUT a 1 PUT b 2 GET a PUT c 3 GET b GET c GET a
Output:
1 -1 3 1

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev