Skip to content

Commit 348f41d

Browse files
committed
Runtime: 3 ms (Top 77.01%) | Memory: 6.3 MB (Top 49.43%)
1 parent 534cfb4 commit 348f41d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/algorithms/C/Count The Repetitions/Count The Repetitions.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 3 ms (Top 77.01%) | Memory: 6.3 MB (Top 49.43%)
12
class Solution {
23
public:
34
int getMaxRepetitions(string s1, int n1, string s2, int n2) {
@@ -9,9 +10,9 @@ class Solution {
910
int repC = count-countr[j2];
1011
int repN = i - indexr[j2];
1112
int remainingN = n1 - i;
12-
//the times that the pattern repeated
13+
//the times that the pattern repeated
1314
count += remainingN/repN * repC;
14-
//the residue at the end of str1, but still might form valid s2
15+
//the residue at the end of str1, but still might form valid s2
1516
int j2_ = seqIndex[indexr[j2]+remainingN%repN];
1617
count += countr[j2_] - countr[j2];
1718
break;
@@ -20,7 +21,7 @@ class Solution {
2021
indexr[j2] = i;
2122
seqIndex.push_back(j2);
2223
}
23-
24+
2425
for (int j1=0; j1<s1.size(); j1++) {
2526
if (s1[j1] == s2[j2]) {
2627
j2++;
@@ -33,4 +34,4 @@ class Solution {
3334
}
3435
return count/n2;
3536
}
36-
};
37+
};

0 commit comments

Comments
 (0)