Design an in-memory key-value store that supports efficient value lookup by key prefix.
Implement the KVStore class:
KVStore()Initialize an in-memory key-value store.void set(String key, int value)Insert a newkey-valuepair. Throw an error if the key already exists.int get(String key)Return the current value forkey, or-1if absent.void update(String key, int value)Overwrite the value for an existingkey. Throw an error if the key is missing.void deleteKey(String key)Removekeyif it exists.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected