#1078
Occurrences After Bigram
pupil · 395 · lc easy +24 · verified · 63.9% accepted · 529 likes · top 67%
Description
Given a text string and two words first and second, find every word that appears immediately after the consecutive pair first second in text.
Return an array of all such following words.
Example 1:
Input: text = "alice is a good girl she is a good student", first = "a", second = "good"
Output: ["girl","student"]
Example 2:
Input: text = "we will we will rock you", first = "we", second = "will"
Output: ["we","rock"]
Code
1
2
3