A support-operations analyst merges a batch of customer ticket transcripts into one block of text and wants to know which word customers repeat the most. A few terms — internal codenames, canned-response boilerplate, and the like — are not meaningful signal and must be excluded from the count. Word matching should ignore case ("Refund" and "refund" are the same word) and should ignore punctuation, splitting the text into words wherever anything other than a letter appears.
text, the merged ticket transcript. It contains English letters, spaces, and the punctuation characters !?'.,;, mixing uppercase and lowercase letters.k, the number of blocked words.k space-separated blocked words, each written in lowercase letters only (this line may be empty when k is 0).Print, in lowercase, the word from text that occurs the most times among words that are not in the blocked list (matching case-insensitively, with punctuation stripped). It is guaranteed that at least one word survives blocking and that the word with the maximum count among non-blocked words is unique.
text <= 1000text (case-insensitively, punctuation stripped) is not in the blocked list.Example 1
Input
Bob hit a ball, the hit BALL flew far after it was hit. 1 hit
Expected
ball
Explanation
Stripping punctuation and lowercasing gives: bob, hit, a, ball, the, hit, ball, flew, far, after, it, was, hit. "hit" occurs 3 times but is blocked. Among the remaining words, "ball" occurs twice (more than any other non-blocked word), so "ball" is printed.
Example 2
Input
a, a, a, a, b,b,b,c, c 0
Expected
a
Explanation
With no blocked words, the counts are a:4, b:3, c:2. "a" has the highest count, so it is printed.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →