-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3324.java
29 lines (27 loc) · 953 Bytes
/
_3324.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.fishercoder.solutions.fourththousand;
import java.util.ArrayList;
import java.util.List;
public class _3324 {
public static class Solution1 {
public List<String> stringSequence(String target) {
List<String> ans = new ArrayList<>();
StringBuilder sb = new StringBuilder();
for (char c : target.toCharArray()) {
char candidate = 'a';
boolean firstTime = true;
do {
if (firstTime) {
firstTime = false;
sb.append(candidate);
} else {
sb.setLength(sb.length() - 1);
candidate = (char) (candidate + 1);
sb.append(candidate);
}
ans.add(sb.toString());
} while (c != candidate);
}
return ans;
}
}
}