Skip to content

Commit 9b29cd4

Browse files
authored
Create 5083-occurrences-after-bigram.js
1 parent c5c0c04 commit 9b29cd4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

5083-occurrences-after-bigram.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} text
3+
* @param {string} first
4+
* @param {string} second
5+
* @return {string[]}
6+
*/
7+
const findOcurrences = function(text, first, second) {
8+
const res = []
9+
let arr = text.split(' ')
10+
for(let i = 1, len = arr.length; i < len; i++) {
11+
if(arr[i] === second && arr[i - 1] === first) {
12+
if(i + 1 < len) res.push(arr[i + 1])
13+
}
14+
}
15+
return res
16+
};

0 commit comments

Comments
 (0)