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fdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrh USING KOTLIN: Given a paragraph and a list of banned words, return the most frequent word that is not in the list
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrh mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrh mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrh
USING KOTLIN: Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isnt banned, and that the answer is unique.
Input: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit." banned = ["hit"] Output: "ball"
What are the steps to solve it?
Convert string to lower case and split by words.
[bob, hit, a, ball, the, hit, ball, flew, far, after, it, was, hit]
2. Create a set of banned words.
[hit]
3. Create a map of words to their occurrence, excluding the banned words.
{bob=1, a=1, ball=2, the=1, flew=1, far=1, after=1, it=1, was=1}
4. Return word with the highest number of occurrences from the map.
ball
Implement those 4 steps in Kotlin.
Write the code using JDoodle,
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm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mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrhmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbvvvccgfdtrtregdffxfdxfcvfhreretryrutgcvbcsadfgdstrh
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started