Insert Delete GetRandom O(1)

Implement RandomizedSet supporting average O(1) time operations:

  • insert(val) -> bool: Insert val if not present and return True; otherwise return False.
  • remove(val) -> bool: Remove ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: