O(1) Get and Add Data Structure
Given a sequence of operations, implement a data structure where all operations run in amortized O(1) time.
You need to support two APIs:
get(key): return the value associated withkeyif ...
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:
