File tree 2 files changed +25
-0
lines changed 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 187
187
1550|[ Three Consecutive Odds] ( ./1550-three-consecutive-odds.js ) |Easy|
188
188
1551|[ Minimum Operations to Make Array Equal] ( ./1551-minimum-operations-to-make-array-equal.js ) |Medium|
189
189
1598|[ Crawler Log Folder] ( ./1598-crawler-log-folder.js ) |Easy|
190
+ 1668|[ Maximum Repeating Substring] ( ./1668-maximum-repeating-substring.js ) |Easy|
190
191
1780|[ Check if Number is a Sum of Powers of Three] ( ./1780-check-if-number-is-a-sum-of-powers-of-three.js ) |Medium|
191
192
1880|[ Check if Word Equals Summation of Two Words] ( ./1880-check-if-word-equals-summation-of-two-words.js ) |Easy|
192
193
1929|[ Concatenation of Array] ( ./1929-concatenation-of-array.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1668. Maximum Repeating Substring
3
+ * https://leetcode.com/problems/maximum-repeating-substring/
4
+ * Difficulty: Easy
5
+ *
6
+ * For a string sequence, a string word is k-repeating if word concatenated k times is a substring
7
+ * of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating
8
+ * in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.
9
+ *
10
+ * Given strings sequence and word, return the maximum k-repeating value of word in sequence.
11
+ */
12
+
13
+ /**
14
+ * @param {string } sequence
15
+ * @param {string } word
16
+ * @return {number }
17
+ */
18
+ var maxRepeating = function ( sequence , word ) {
19
+ let count = Math . floor ( sequence . length / word . length ) + 1 ;
20
+ while ( -- count ) {
21
+ if ( sequence . includes ( word . repeat ( count ) ) ) return count ;
22
+ }
23
+ return count ;
24
+ } ;
You can’t perform that action at this time.
0 commit comments