#C13957. Most Frequent Word
Most Frequent Word
Most Frequent Word
You are given a string of text. Your task is to determine the most frequent word in the text. In case of a tie, return the word that appears first in the input text.
The solution must ignore punctuation and treat uppercase and lowercase letters as equivalent. Formally, let \( f(w) \) denote the frequency of word \( w \) in the text. If there exist words \( w_1, w_2, \ldots, w_k \) such that \( f(w_1) = f(w_2) = \cdots = f(w_k) = M \) (where \( M \) is the maximum frequency), then return the word \( w_i \) with the smallest index (i.e. first appearance in the input order).
inputFormat
The input is provided via stdin
and consists of a single line containing the text. The text is composed of words separated by spaces and may include punctuation.
outputFormat
Output the most frequent word as described. The output should be printed to stdout
.
hello
hello