Alice and Bob are playing a game. Initially, Alice has a string word = "a".
You are given a positive integer k.
Now Bob will ask Alice to perform the following operation forever:
For example, performing the operation on "c" generates "cd" and performing the operation on "zb" generates "zbac".
Return the value of the kth character in word, after enough operations have been done for word to have at least k characters.
Examples
Example 1
Input: k = 5
Output: "b"
Explanation:
Initially, word = "a" . We need to do the operation three times:
Example 2
Input: k = 10
Output: "c"
Constraints
1 <= k <= 500
3304. Find the K-th Character in String Game I
Easy
10 Points
Math
Bit Manipulation
Recursion
Simulation
Alice and Bob are playing a game. Initially, Alice has a string word = "a".
You are given a positive integer k.
Now Bob will ask Alice to perform the following operation forever:
For example, performing the operation on "c" generates "cd" and performing the operation on "zb" generates "zbac".
Return the value of the kth character in word, after enough operations have been done for word to have at least k characters.
Examples
Example 1
Input: k = 5
Output: "b"
Explanation:
Initially, word = "a" . We need to do the operation three times:
Example 2
Input: k = 10
Output: "c"
Constraints
1 <= k <= 500
Find the K-th Character in String Game I - Practice Coding | SlaveCode