hardBit ManipulationMathRecursion 0 views

Find the K-th Character in String Game II

Alice and Bob are playing a game.

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 array operations, where operations[i] represents the type of the ith operation.

Now Bob will ask Alice to perform all operations in sequence:

Return the value of the kth character in word after performing all the operations.

Note that the character 'z' can be changed to 'a' in the second type of operation.

Find the K-th Character in String Game II diagram

Example 1

Input: k = 5, operations = [0,0,0]

Output: "a"

Explanation: Initially, word == "a" . Alice performs the three operations as follows:

Example 2

Input: k = 10, operations = [0,1,0,1]

Output: "b"

Explanation: Initially, word == "a" . Alice performs the four operations as follows:

Constraints

  • 1 <= k <= 1014
  • 1 <= operations.length <= 100
  • operations[i] is either 0 or 1.
  • The input is generated such that word has at least k characters after all operations.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.