Problem Description

You have cache capacity cap. Commands: GET key, PUT key value. For GET output value if present else -1. LRU eviction is used when capacity exceeded.

Input Format

First line cap. Second line q. Next q lines commands.

Output Format

Outputs for GET commands.

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

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next