523. Password Decoder
0
Medium
Given an encoded string s, Manu needs to decode it to a tape by following these steps:
1. Read the encoded string one character at a time.
2. If the character is a letter, write it onto the tape.
3. If the character is a digit d, write the entire current tape d - 1 more times in total.
Manu wants to find the kth letter (1-indexed) in the decoded string. Help Manu by returning the desired letter.
Manu wants to find the kth letter (1-indexed) in the decoded string. Help Manu by returning the desired letter.
Input Format
The first line contains a string.
The second line contains an integer k.
The second line contains an integer k.
Output Format
Print the kth letter (1-indexed) in the decoded string.
Example
Input
leet2code3
10
Output
o
Constraints
2 <= s.length <= 100
s consists of lowercase English letters and digits 2 through 9.
s starts with a letter.
1 <= k <= 109
It is guaranteed that k is less than or equal to the length of the decoded string.
The decoded string is guaranteed to have less than 263 letters.
s consists of lowercase English letters and digits 2 through 9.
s starts with a letter.
1 <= k <= 109
It is guaranteed that k is less than or equal to the length of the decoded string.
The decoded string is guaranteed to have less than 263 letters.
Loading...
View Submissions
Console