Skip to content

Commit 4410dca

Browse files
[LEET-3324] add 3324
1 parent be32346 commit 4410dca

File tree

3 files changed

+54
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+54
-0
lines changed

paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
33
| 3330 | [Find the Original Typed String I](https://leetcode.com/problems/find-the-original-typed-string-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3330.java) | | Easy |
4+
| 3324 | [Find the Sequence of Strings Appeared on the Screen](https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3324.java) | | Easy |
45
| 3318 | [Find X-Sum of All K-Long Subarrays I](https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3318.java) | | Easy |
56
| 3314 | [Construct the Minimum Bitwise Array I](https://leetcode.com/problems/construct-the-minimum-bitwise-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3314.java) | | Easy |
67
| 3304 | [Find the K-th Character in String Game I](https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3304.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class _3324 {
7+
public static class Solution1 {
8+
public List<String> stringSequence(String target) {
9+
List<String> ans = new ArrayList<>();
10+
StringBuilder sb = new StringBuilder();
11+
for (char c : target.toCharArray()) {
12+
char candidate = 'a';
13+
boolean firstTime = true;
14+
do {
15+
if (firstTime) {
16+
firstTime = false;
17+
sb.append(candidate);
18+
} else {
19+
sb.setLength(sb.length() - 1);
20+
candidate = (char) (candidate + 1);
21+
sb.append(candidate);
22+
}
23+
ans.add(sb.toString());
24+
} while (c != candidate);
25+
}
26+
return ans;
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder.fourththousand;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import com.fishercoder.solutions.fourththousand._3324;
6+
import java.util.Arrays;
7+
import org.junit.jupiter.api.BeforeEach;
8+
import org.junit.jupiter.api.Test;
9+
10+
public class _3324Test {
11+
private _3324.Solution1 solution1;
12+
13+
@BeforeEach
14+
public void setup() {
15+
solution1 = new _3324.Solution1();
16+
}
17+
18+
@Test
19+
public void test1() {
20+
assertEquals(
21+
Arrays.asList("a", "aa", "ab", "aba", "abb", "abc"),
22+
solution1.stringSequence("abc"));
23+
}
24+
}

0 commit comments

Comments
 (0)