Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 690c27b

Browse files
Create README - LeetHub
1 parent 1942c5e commit 690c27b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

‎819-most-common-word/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<h2><a href="https://leetcode.com/problems/most-common-word/">819. Most Common Word</a></h2><h3>Easy</h3><hr><div><p>Given a string <code>paragraph</code> and a string array of the banned words <code>banned</code>, return <em>the most frequent word that is not banned</em>. It is <strong>guaranteed</strong> there is <strong>at least one word</strong> that is not banned, and that the answer is <strong>unique</strong>.</p>
2+
3+
<p>The words in <code>paragraph</code> are <strong>case-insensitive</strong> and the answer should be returned in <strong>lowercase</strong>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
8+
<pre><strong>Input:</strong> paragraph = "Bob hit a ball, the hit BALL flew far after it was hit.", banned = ["hit"]
9+
<strong>Output:</strong> "ball"
10+
<strong>Explanation:</strong>
11+
"hit" occurs 3 times, but it is a banned word.
12+
"ball" occurs twice (and no other word does), so it is the most frequent non-banned word in the paragraph.
13+
Note that words in the paragraph are not case sensitive,
14+
that punctuation is ignored (even if adjacent to words, such as "ball,"),
15+
and that "hit" isn't the answer even though it occurs more because it is banned.
16+
</pre>
17+
18+
<p><strong>Example 2:</strong></p>
19+
20+
<pre><strong>Input:</strong> paragraph = "a.", banned = []
21+
<strong>Output:</strong> "a"
22+
</pre>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Constraints:</strong></p>
26+
27+
<ul>
28+
<li><code>1 &lt;= paragraph.length &lt;= 1000</code></li>
29+
<li>paragraph consists of English letters, space <code>' '</code>, or one of the symbols: <code>"!?',;."</code>.</li>
30+
<li><code>0 &lt;= banned.length &lt;= 100</code></li>
31+
<li><code>1 &lt;= banned[i].length &lt;= 10</code></li>
32+
<li><code>banned[i]</code> consists of only lowercase English letters.</li>
33+
</ul>
34+
</div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /