LRU Cache Class

Programming Interview Hard 8 views
Back to Questions

Problem Description

Cache capacity cap is provided and q commands: PUT k v, GET k. Implement LRUCache class. For GET output value or -1.

Input Format

Line1 cap. Line2 q. Next q lines commands.

Output Format

Outputs for GET.

Sample Test Case

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

Constraints

cap,q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next