Skip to content

Commit d1aaf67

Browse files
committed
Runtime: 28 ms (Top 95.86%) | Memory: 64.6 MB (Top 55.86%)
1 parent 632207b commit d1aaf67

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

scripts/algorithms/C/Construct String With Repeat Limit/Construct String With Repeat Limit.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 28 ms (Top 95.86%) | Memory: 64.6 MB (Top 55.86%)
12
class Solution {
23
public String repeatLimitedString(String s, int repeatLimit) {
34
int[] counter = new int[26];
@@ -16,11 +17,11 @@ public String repeatLimitedString(String s, int repeatLimit) {
1617
if (counter[max] == 0) {
1718
max = findNextMax(counter, max - 1);
1819
repeated = 0;
19-
continue;
20-
}
20+
continue;
21+
}
2122
if (repeated == repeatLimit) {
22-
// Greedy, use the next possible char once and get back to curr.
23-
// if no other char available, the curr word is the largest subsequence.
23+
// Greedy, use the next possible char once and get back to curr.
24+
// if no other char available, the curr word is the largest subsequence.
2425
int lower = findNextMax(counter, max - 1);
2526
if (lower < 0) {
2627
return builder.toString();
@@ -32,7 +33,7 @@ public String repeatLimitedString(String s, int repeatLimit) {
3233
}
3334
return builder.toString();
3435
}
35-
36+
3637
private int findNextMax(int[] counter, int from) {
3738
int curr = from;
3839
while (curr >= 0) {
@@ -43,4 +44,4 @@ private int findNextMax(int[] counter, int from) {
4344
}
4445
return curr;
4546
}
46-
}
47+
}

0 commit comments

Comments
 (0)