Trains the technique from
LeetCode 3304Find the K-th Character in String Game IThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A label generator keeps one word, which starts out as the single letter "a".
In one round the generator takes the word it currently holds, makes a copy in which every letter is replaced by the next letter of the alphabet, so 'a' becomes 'b', 'b' becomes 'c' and so on, and then sticks that copy on the end of the word. The word therefore doubles in length each round: after the first round it reads "ab", after the second "abbc".
Rounds keep running until the word holds at least k letters. Return the k-th letter of the word, counting the first letter as position 1. The bound on k keeps every letter within the alphabet, so no letter ever has to step past 'z'.
Example 1
After two rounds the word reads `"abbc"`, which already holds four letters, and its fourth letter is `"c"`.
Example 2
After three rounds the word reads `"abbcbccd"`, and its eighth letter is `"d"`.
Example 3
Four rounds give `"abbcbccdbccdcdde"`. Its twelfth letter is `"d"`.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def kth_character(k: int) -> str:public char kthCharacter(int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.