Skip to content

Practice Decoded String at Index

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#880
LeetCode Problem

Decoded String at Index

Problem Statement

Read encoded string s from left to right. A letter appends that letter to a tape. A digit d replaces the entire current tape by d copies of itself, adding d - 1 further copies. Return the letter at the valid one-based position k in the final decoded tape.

Source: Decoded String at Index on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leet2code3", k = 10
Output
"o"

# Example 2

Input
s = "ha22", k = 5
Output
"h"

# Example 3

Input
s = "a2345678999999999999999", k = 1
Output
"a"

Constraints

2 <= s.length <= 100
s consists of lowercase English letters and digits 2 through 9.
s starts with a letter.
1 <= k <= 10^9
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 2^63 letters.

Related LeetCode Problems

Practice more problems similar to Decoded String at Index.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.