Medium
040Insert Delete GetRandom O(1)
Simulate insert, remove, and getRandom with deterministic random indices. Return 1/0 for insert/remove and selected values for getRandom.
EXAMPLES
Example 1
Input
{
"operations": [
"insert",
"remove",
"insert",
"getRandom"
],
"values": [
1,
2,
2,
0
],
"randomIndices": [
0
]
}
Output
[
1,
0,
1,
1
]FUNCTION SHAPE
operations: stringArrayvalues: intArrayrandomIndices: intArray→intArray