You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An encoded string S is given. To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:
6
+
7
+
If the character read is a letter, that letter is written onto the tape.
8
+
If the character read is a digit (say d), the entire current tape is repeatedly written d-1 more times in total.
9
+
Now for some encoded string S, and an index K, find and return the K-th letter (1 indexed) in the decoded string.
10
+
11
+
Example 1:
12
+
Input: S = "leet2code3", K = 10
13
+
Output: "o"
14
+
Explanation:
15
+
The decoded string is "leetleetcodeleetleetcodeleetleetcode".
16
+
The 10th letter in the string is "o".
17
+
18
+
Example 2:
19
+
Input: S = "ha22", K = 5
20
+
Output: "h"
21
+
Explanation:
22
+
The decoded string is "hahahaha". The 5th letter is "h".
23
+
24
+
Example 3:
25
+
Input: S = "a2345678999999999999999", K = 1
26
+
Output: "a"
27
+
Explanation:
28
+
The decoded string is "a" repeated 8301530446056247680 times. The 1st letter is "a".
29
+
30
+
Constraints:
31
+
2 <= S.length <= 100
32
+
S will only contain lowercase letters and digits 2 through 9.
33
+
S starts with a letter.
34
+
1 <= K <= 10^9
35
+
It's guaranteed that K is less than or equal to the length of the decoded string.
36
+
The decoded string is guaranteed to have less than 2^63 letters.
| 20. |[Decoded String at Index](https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/571/week-3-december-15th-december-21st/3572/)|[cpp](./20.%20Decoded%20String%20at%20Index.cpp)|
25
25
| 21. |[Smallest Range II](https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/571/week-3-december-15th-december-21st/3573/)|[cpp](./21.%20Smallest%20Range%20II.cpp)|
0 commit comments