Most Frequent Non-Banned Word Problem Statement
Given a paragraph consisting of letters in both lowercase and uppercase, spaces, and punctuation, along with a list of banned words, your task is to find the most frequent word that is not in the list of banned words. The solution will always exist and be unique.
While considering words, treat letters as case-insensitive (e.g., 'AsK' and 'aSK' are the same). Words consist solely of alphabets, separated by spaces or punctuation, and the result should be returned in uppercase.
Example:
Input:
Paragraph = "It's a square SqUare. It's a FLAT flat."
N = 3
BANNEDWORDS = [ "FLAT", "IT", "S" ]
Output:
SQUARE
Explanation:
The most frequent words (case-insensitive) are [IT, S, SQUARE, FLAT], each appearing twice. After checking with the banned list, 'SQUARE' remains as the most frequent word not banned, with a frequency of 2.
Constraints:
1 <= N <= 106
(where N is the size of the paragraph)1 <= banned.size <= 100
- Time limit: 1 second
Note:
You do not need to output anything as it's handled elsewhere. Your task is to implement the given function.
Top Standard Chartered Full Stack Developer interview questions & answers
Popular interview questions of Full Stack Developer
Reviews
Interviews
Salaries
Users/Month