Decoded String at Index
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
An encoded string s is decoded into a tape by reading it from left to right:
- A letter is appended to the end of the tape.
- A digit d (from 2 to 9) replaces the tape with d back-to-back copies of itself.
Given s and a 1-indexed position k, return the k-th character of the fully decoded tape as a one-character string. The decoded tape can be astronomically long (far beyond memory), so you must not build it. k is guaranteed not to exceed the tape length.
Examples
Constraints
- `2 <= s.length <= 100`
- `s` has lowercase letters and digits `2`-`9`, and starts with a letter
- `1 <= k <= 10^9`
- `k` does not exceed the decoded length
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.