#C111. Basic Spell Checker
Basic Spell Checker
Basic Spell Checker
You are required to implement a basic spell checker as a dictionary. Initially, the dictionary is empty. The program will receive a sequence of commands, where each command is one of the following:
ADD word
: Add the given word to the dictionary. If the word is already present, nothing changes.CHECK word
: Check if the given word is present in the dictionary. The check is case-sensitive, meaning that, for example,apple
andApple
are considered distinct.
For each CHECK
command, output either Correct
if the word exists in the dictionary or Incorrect
if it does not. The problem tests your implementation of basic data storage and lookup functionality.
inputFormat
The input begins with an integer ( n ) denoting the total number of commands. Each of the next ( n ) lines contains a command in one of the two formats:
ADD word
CHECK word
Here, word
is a non-empty string without spaces.
outputFormat
For every CHECK
command in the input, output a single line with the result:
Correct
if the word is present in the dictionary.Incorrect
if the word is not present in the dictionary.
Each output should be printed on its own line.## sample
4
ADD hello
ADD world
CHECK hello
CHECK world
Correct
Correct
</p>