3307. Find the K-th Character in String Game II
Alice and Bob are playing a game. Initially, Alice has a string
word = "a"
.You are given a positive integer
k
. You are also given an integer arrayoperations
, whereoperations[i]
represents the type of theith
operation.Now Bob will ask Alice to perform all operations in sequence:
- If
operations[i] == 0
, append a copy ofword
to itself.- If
operations[i] == 1
, generate a new string by changing each character inword
to its next character in the English alphabet, and append it to the originalword
. For example, performing the operation on"c"
generates"cd"
and performing the operation on"zb"
generates"zbac"
.Return the value of the
kth
character inword
after performing all the operations.Note that the character
'z'
can be changed to'a'
in the second type of operation.
1 | package main |