Dynamic Random Pick with Add and Remove Key

Problem: Dynamic Weighted Random Key Generator

Design a class RandomKeyGenerator that supports the following operations:

  1. add_key(key: str) -> None
    • Add one occurrence of key.
    • If...

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: