Tap here to switch tabs
Problem
Submissions

Problem: Most Common Word

med
30 min
Try to solve the Most Common Word problem.

Statement

Given a string paragraph and an array of banned words banned, return the most frequent word that is not banned.

The words in paragraph are case insensitive, and the returned result must be in lowercase. Punctuation symbols in paragraph are ignored. It is guaranteed that there is at least one word that is not banned, and the answer is unique.

Constraints:

  • 1≤1 \leq paragraph.length ≤1000\leq 1000

  • paragraph consists of English letters, space ' ', or one of the symbols: "!?',;.".

  • 0≤0 \leq banned.length ≤100\leq 100

  • 1≤1 \leq banned[i].length ≤10\leq 10

  • banned[i] consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Common Word

med
30 min
Try to solve the Most Common Word problem.

Statement

Given a string paragraph and an array of banned words banned, return the most frequent word that is not banned.

The words in paragraph are case insensitive, and the returned result must be in lowercase. Punctuation symbols in paragraph are ignored. It is guaranteed that there is at least one word that is not banned, and the answer is unique.

Constraints:

  • 1≤1 \leq paragraph.length ≤1000\leq 1000

  • paragraph consists of English letters, space ' ', or one of the symbols: "!?',;.".

  • 0≤0 \leq banned.length ≤100\leq 100

  • 1≤1 \leq banned[i].length ≤10\leq 10

  • banned[i] consists of only lowercase English letters.