Skip to content

Commit 8c80a63

Browse files
[LEET-3304] add 3304
1 parent fd3a747 commit 8c80a63

File tree

3 files changed

+28
-8
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+28
-8
lines changed

Diff for: 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
| 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 |
4+
| 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 |
45
| 3285 | [Find Indices of Stable Mountains](https://leetcode.com/problems/find-indices-of-stable-mountains/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3285.java) | | Easy |
56
| 3264 | [Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3264.java) | | Easy |
67
| 3263 | [Convert Doubly Linked List to Array I](https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3263.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
package com.fishercoder.solutions.fourththousand;public class _3304 {
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3304 {
4+
public static class Solution1 {
5+
public char kthCharacter(int k) {
6+
StringBuilder sb = new StringBuilder("a");
7+
while (sb.length() <= k) {
8+
int n = sb.length();
9+
for (int i = 0; i < n; i++) {
10+
sb.append((char) (sb.charAt(i) + 1));
11+
}
12+
}
13+
return sb.charAt(k - 1);
14+
}
15+
}
216
}
+12-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
package com.fishercoder.fourththousand;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
5-
import com.fishercoder.solutions.fourththousand._3185;
3+
import com.fishercoder.solutions.fourththousand._3304;
64
import org.junit.jupiter.api.BeforeEach;
75
import org.junit.jupiter.api.Test;
86

9-
public class _3185Test {
10-
private _3185.Solution1 solution1;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class _3304Test {
10+
private _3304.Solution1 solution1;
1111

1212
@BeforeEach
1313
public void setup() {
14-
solution1 = new _3185.Solution1();
14+
solution1 = new _3304.Solution1();
1515
}
1616

1717
@Test
1818
public void test1() {
19-
assertEquals(2, solution1.countCompleteDayPairs(new int[] {12, 12, 30, 24, 24}));
19+
assertEquals('b', solution1.kthCharacter(5));
20+
}
21+
22+
@Test
23+
public void test2() {
24+
assertEquals('h', solution1.kthCharacter(128));
2025
}
2126
}

0 commit comments

Comments
 (0)