Skip to content

3307. Find the K-th Character in String Game II #1886

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine the k-th character in a string after performing a series of operations. The string starts as "a", and each operation either appends a copy of the current string to itself (operation 0) or appends a transformed version of the string where each character is incremented by 1 in the alphabet (operation 1, with 'z' wrapping around to 'a'). Given that k can be as large as 1014 and the number of operations can be up to 100, we need an efficient approach that avoids explicitly constructing the string.

Approach

  1. Problem Analysis: The key observation is that each operation doubles the length of the string. For operation 0, the second half is an exact copy of the first half. Fo…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Jul 4, 2025
Maintainer Author

You must be logged in to vote
2 replies
@kovatz
Comment options

kovatz Jul 4, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jul 4, 2025
Maintainer Author

Answer selected by kovatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested hard Difficulty
2 participants