#C13978. Most Common Word
Most Common Word
Most Common Word
Given a sentence, your task is to find the most frequently occurring word. The comparison should be performed in a case-insensitive manner and all punctuation should be ignored. In case of a tie (i.e. when more than one word has the maximum frequency), return the word that appears first in the sentence.
For the purpose of this problem, a word is defined as a contiguous sequence of alphanumeric characters. In mathematical terms, if we denote a word by the regular expression $\\b\\w+\\b$
, then your solution should consider all such subsequences in the input.
If the input sentence is empty or does not contain any valid word, print an empty string.
inputFormat
The input is provided via standard input (stdin) and consists of a single line containing a sentence. The sentence may include letters, digits, punctuation, and spaces.
outputFormat
Output the most frequently occurring word to standard output (stdout). The output should be exactly the word, with no extra spaces or newline characters (beyond what is necessary).
## sampleThis is a test. This test is only a test.
test