Learn
Practice
Newsletter
Resources
Resume
New
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Insert Delete GetRandom O(1)
Bookmark
Input
Example 1
Example 2
Example 3
Custom
operations
=
[RandomizedSet, insert, insert, remove, insert, getRandom, remove]
,
values
=
[null, 1, 2, 1, 2, null, 2]
Operation
—
Result
—
Array List
(empty)
HashMap (val → index)
(empty)
algo
master
.
io
Step:
Initialize RandomizedSet with empty array and HashMap
0 / 25
Input
Example 1
Example 2
Example 3
Custom
operations
=
[RandomizedSet, insert, insert, remove, insert, getRandom, remove]
,
values
=
[null, 1, 2, 1, 2, null, 2]
0 / 25
Operation
—
Result
—
Array List
(empty)
HashMap (val → index)
(empty)
algo
master
.
io
Step:
Initialize RandomizedSet with empty array and HashMap