File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,126 LeetCode solutions in JavaScript
1
+ # 1,127 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
865
865
1072|[ Flip Columns For Maximum Number of Equal Rows] ( ./solutions/1072-flip-columns-for-maximum-number-of-equal-rows.js ) |Medium|
866
866
1073|[ Adding Two Negabinary Numbers] ( ./solutions/1073-adding-two-negabinary-numbers.js ) |Medium|
867
867
1074|[ Number of Submatrices That Sum to Target] ( ./solutions/1074-number-of-submatrices-that-sum-to-target.js ) |Hard|
868
+ 1078|[ Occurrences After Bigram] ( ./solutions/1078-occurrences-after-bigram.js ) |Easy|
868
869
1079|[ Letter Tile Possibilities] ( ./solutions/1079-letter-tile-possibilities.js ) |Medium|
869
870
1081|[ Smallest Subsequence of Distinct Characters] ( ./solutions/1081-smallest-subsequence-of-distinct-characters.js ) |Medium|
870
871
1092|[ Shortest Common Supersequence] ( ./solutions/1092-shortest-common-supersequence.js ) |Hard|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1078. Occurrences After Bigram
3
+ * https://leetcode.com/problems/occurrences-after-bigram/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given two strings first and second, consider occurrences in some text of the form "first second
7
+ * third", where second comes immediately after first, and third comes immediately after second.
8
+ *
9
+ * Return an array of all the words third for each occurrence of "first second third".
10
+ */
11
+
12
+ /**
13
+ * @param {string } text
14
+ * @param {string } first
15
+ * @param {string } second
16
+ * @return {string[] }
17
+ */
18
+ var findOcurrences = function ( text , first , second ) {
19
+ const words = text . split ( ' ' ) ;
20
+ const result = [ ] ;
21
+
22
+ for ( let i = 0 ; i < words . length - 2 ; i ++ ) {
23
+ if ( words [ i ] === first && words [ i + 1 ] === second ) {
24
+ result . push ( words [ i + 2 ] ) ;
25
+ }
26
+ }
27
+
28
+ return result ;
29
+ } ;
You can’t perform that action at this time.
0 commit comments