#C14093. Common Words Across Sentences
Common Words Across Sentences
Common Words Across Sentences
You are given a list of sentences. Your task is to find all words that appear in every sentence. The matching of words is case-insensitive so that, for example, Apple
and apple
are considered the same. All returned words must be in lowercase.
Words are defined as sequences of alphanumeric characters (i.e. letters and digits) separated by non-alphanumeric characters. You are not allowed to use any built-in methods or functions that trivialize this task.
To ensure consistent output, print the common words in alphabetical order, separated by a single space. If there are no common words among the sentences, output an empty line.
Note: The input will be provided via standard input and the output must be printed to standard output.
Example:
Input: 3 Apple banana banana cherry banana apple</p>Output: banana
inputFormat
The first line of input contains an integer n, the number of sentences. Each of the next n lines contains one sentence.
outputFormat
Print a single line with the common words, sorted in alphabetical order, separated by a single space. If there are no common words, print an empty line.
## sample3
Apple banana
banana cherry
banana apple
banana
</p>