File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ _If you like this project, please leave me a star._ ★
172
172
| 885| [ Spiral Matrix III] ( https://leetcode.com/problems/spiral-matrix-iii/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_885.java ) | [ :tv : ] ( https://www.youtube.com/watch?v=0qep3f9cqVs ) | Medium|
173
173
| 884| [ Uncommon Words from Two Sentences] ( https://leetcode.com/problems/uncommon-words-from-two-sentences/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_884.java ) | | Easy|
174
174
|883|[ Projection Area of 3D Shapes] ( https://leetcode.com/problems/projection-area-of-3d-shapes/ ) |[ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_883.java ) | |Easy|Math
175
+ |880|[ Decoded String at Index] ( https://leetcode.com/problems/decoded-string-at-index/ ) |[ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_880.java ) | |Medium|Stack
175
176
| 876| [ Middle of the Linked List] ( https://leetcode.com/problems/middle-of-the-linked-list/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_876.java ) | | Easy|
176
177
|872|[ Leaf-Similar Trees] ( https://leetcode.com/problems/leaf-similar-trees/ ) |[ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_872.java ) | |Easy| DFS, recursion
177
178
| 868| [ Binary Gap] ( https://leetcode.com/problems/binary-gap/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_868.java ) | | Easy|
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ /**
4
+ * 880. Decoded String at Index
5
+ *
6
+ * An encoded string S is given. To find and write the decoded string to a tape,
7
+ * the encoded string is read one character at a time and the following steps are taken:
8
+ * If the character read is a letter, that letter is written onto the tape.
9
+ * If the character read is a digit (say d), the entire current tape is repeatedly written d-1 more times in total.
10
+ * Now for some encoded string S, and an index K, find and return the K-th letter (1 indexed) in the decoded string.
11
+ *
12
+ * Example 1:
13
+ * Input: S = "leet2code3", K = 10
14
+ * Output: "o"
15
+ * Explanation:
16
+ * The decoded string is "leetleetcodeleetleetcodeleetleetcode".
17
+ * The 10th letter in the string is "o".
18
+ *
19
+ * Example 2:
20
+ * Input: S = "ha22", K = 5
21
+ * Output: "h"
22
+ * Explanation:
23
+ * The decoded string is "hahahaha". The 5th letter is "h".
24
+ *
25
+ * Example 3:
26
+ * Input: S = "a2345678999999999999999", K = 1
27
+ * Output: "a"
28
+ * Explanation:
29
+ * The decoded string is "a" repeated 8301530446056247680 times. The 1st letter is "a".
30
+ *
31
+ * Note:
32
+ * 2 <= S.length <= 100
33
+ * S will only contain lowercase letters and digits 2 through 9.
34
+ * S starts with a letter.
35
+ * 1 <= K <= 10^9
36
+ * The decoded string is guaranteed to have less than 2^63 letters.
37
+ * */
38
+ public class _880 {
39
+ public static class Solution1 {
40
+ public String decodeAtIndex (String S , int K ) {
41
+ //TODO: implement it
42
+ return "" ;
43
+ }
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder ;
2
+
3
+ import com .fishercoder .solutions ._880 ;
4
+ import org .junit .BeforeClass ;
5
+ import org .junit .Ignore ;
6
+ import org .junit .Test ;
7
+
8
+ import static org .junit .Assert .assertEquals ;
9
+
10
+ @ Ignore
11
+ public class _880Test {
12
+ private static _880 .Solution1 solution1 ;
13
+
14
+ @ BeforeClass
15
+ public static void setup () {
16
+ solution1 = new _880 .Solution1 ();
17
+ }
18
+
19
+ @ Test
20
+ public void test1 () {
21
+ assertEquals ("o" , solution1 .decodeAtIndex ("leet2code3" , 10 ));
22
+ }
23
+
24
+ @ Test
25
+ public void test2 () {
26
+ assertEquals ("h" , solution1 .decodeAtIndex ("ha22" , 5 ));
27
+ }
28
+
29
+ @ Test
30
+ public void test3 () {
31
+ assertEquals ("a" , solution1 .decodeAtIndex ("a2345678999999999999999" , 1 ));
32
+ }
33
+
34
+ @ Test
35
+ public void test4 () {
36
+ assertEquals ("a" , solution1 .decodeAtIndex ("abc" , 1 ));
37
+ }
38
+
39
+ @ Test
40
+ public void test5 () {
41
+ assertEquals ("a" , solution1 .decodeAtIndex ("a2b3c4d5e6f7g8h9" , 10 ));
42
+ }
43
+
44
+ }
You can’t perform that action at this time.
0 commit comments