Description
You are given an encoded string s. To decode it, follow: if the character is a letter, append it; if it is a digit d, repeat the current string d-1 more times. Return the kth letter (1-indexed) in the decoded string.
Examples
Input:
s = "leet2code3", k = 10Output:
"o"Explanation:
Decoded: leetleetcodeleetleetcodeleetleetcode
Input:
s = "a", k = 10Output:
"o"Explanation:
Edge case with a single character.
Input:
s = "abc2def4", k = 15Output:
cExplanation:
First, 'abc' gives us 'abc'. Then '2' repeats it: 'abcabc' (length 6). Next, 'def' is appended: 'abcabcdef' (length 9). Finally, '4' repeats the entire string 4 times: 'abcabcdefabcabcdefabcabcdefabcabcdef' (length 36). The 15th character is 'c'.
Constraints
- •
2 ≤ s.length ≤ 100 - •
s consists of lowercase letters and digits 2-9