今天快陣亡了,先放 code
class Solution:
def decodeAtIndex(self, s: str, k: int) -> str:
size = 0
for c in s:
if c.isdigit():
size *= int(c)
else:
size += 1
for c in s[::-1]:
if c.isdigit():
size //= int(c)
k %= size
else:
if k == size or k == 0:
return c
size -= 1