-
Notifications
You must be signed in to change notification settings - Fork 160
/
occurrences-after-bigram.md
32 lines (23 loc) · 1.59 KB
/
occurrences-after-bigram.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<p>Given words <code>first</code> and <code>second</code>, consider occurrences in some <code>text</code> of the form "<code>first second third</code>", where <code>second</code> comes immediately after <code>first</code>, and <code>third</code> comes immediately after <code>second</code>.</p>
<p>For each such occurrence, add "<code>third</code>" to the answer, and return the answer.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong>text = <span id="example-input-1-1">"alice is a good girl she is a good student"</span>, first = <span id="example-input-1-2">"a"</span>, second = <span id="example-input-1-3">"good"</span>
<strong>Output: </strong><span id="example-output-1">["girl","student"]</span>
</pre>
<div>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong>text = <span id="example-input-2-1">"we will we will rock you"</span>, first = <span id="example-input-2-2">"we"</span>, second = <span id="example-input-2-3">"will"</span>
<strong>Output: </strong><span id="example-output-2">["we","rock"]</span>
</pre>
<p> </p>
<p><strong>Note:</strong></p>
<ol>
<li><code>1 <= text.length <= 1000</code></li>
<li><code>text</code> consists of space separated words, where each word consists of lowercase English letters.</li>
<li><code>1 <= first.length, second.length <= 10</code></li>
<li><code>first</code> and <code>second</code> consist of lowercase English letters.</li>
</ol>
</div>