Back
Close
  • 32

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

In this puzzle, your task is to implement a key-value store that supports the following commands:

➤SET key1=value1 key2=value2 ...
Create a new key or update the value if the key already exists.
Nothing to print.

➤GET key1 key2 ...
Print the corresponding value for each key, or null if it doesn't exist.

➤EXISTS key1 key2 ...
Print true or false for each key, depending on whether it exists.

➤KEYS
Print all stored keys in the same order they were first set or print EMPTY if no keys are present

Output should be space-separated for GET, EXISTS and KEYS.
Input
Line 1: An integer N— the number of instructions.
Next N lines: Each line contains a single instruction S.
Output
Print the result of each command based on the rules above
Constraints
3 < N < 30
Keys and values in S do not contain spaces or =
Example
Input
3
SET os-name=windows
SET os-arch=x64
GET os-name os-arch
Output
windows x64

A higher resolution is required to access the IDE