Tap here to switch tabs
Problem
Submissions

Problem: Decoded String at Index

med
30 min
Try to solve the Decoded String at Index problem.

Statement

You are given an encoded string s and an integer k.

The encoded string is decoded to a tape by reading characters one by one according to the following rules:

  • If the character read is a letter, that character is appended to the tape.

  • If the character read is a digit dd, the entire current tape is repeated dd times in total.

Return the kextthk^{ ext{th}} letter (11 indexed) in the decoded string.

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters and digits from 22 through 99.

  • s starts with a letter.

  • 1≤1 \leq k ≤109\leq 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 2632^{63} letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Decoded String at Index

med
30 min
Try to solve the Decoded String at Index problem.

Statement

You are given an encoded string s and an integer k.

The encoded string is decoded to a tape by reading characters one by one according to the following rules:

  • If the character read is a letter, that character is appended to the tape.

  • If the character read is a digit dd, the entire current tape is repeated dd times in total.

Return the kextthk^{ ext{th}} letter (11 indexed) in the decoded string.

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters and digits from 22 through 99.

  • s starts with a letter.

  • 1≤1 \leq k ≤109\leq 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 2632^{63} letters.