Medium
076LRU Cache
Simulate an LRU cache. Operations are put and get. Return outputs for get operations.
EXAMPLES
Example 1
Input
{
"capacity": 2,
"operations": [
"put",
"put",
"get",
"put",
"get",
"put",
"get",
"get",
"get"
],
"values": [
[
1,
1
],
[
2,
2
],
[
1
],
[
3,
3
],
[
2
],
[
4,
4
],
[
1
],
[
3
],
[
4
]
]
}
Output
[
1,
-1,
-1,
3,
4
]FUNCTION SHAPE
capacity: intoperations: stringArrayvalues: intMatrix→intArray