#C86. Autocomplete with Case-Insensitive Matching

    ID: 52599 Type: Default 1000ms 256MiB

Autocomplete with Case-Insensitive Matching

Autocomplete with Case-Insensitive Matching

You are given a prefix string and a dictionary of words. Your task is to output all the words from the dictionary that start with the given prefix. The comparisons must be done in a case-insensitive manner, i.e. convert both the prefix and the dictionary words to lowercase before comparing.

For example, if the dictionary is ["apple", "application", "Appetite", "banana", "Berry"] and the prefix is "app", the correct output is "apple application Appetite" (preserving the original order of appearance).

inputFormat

Input is read from standard input. The input format is as follows:

  • The first line contains the prefix string.
  • The second line contains an integer N, representing the number of words in the dictionary.
  • The following N lines each contain one word from the dictionary.

outputFormat

Output to standard output a single line containing the words that start with the given prefix (using case-insensitive comparison), separated by a single space. If no word matches, output an empty line.## sample

app
5
apple
application
Appetite
banana
Berry
apple application Appetite