LeetCode solutions

3600. Find the K-th Character in String Game I

My accepted Python solution to LeetCode problem 3600, Find the K-th Character in String Game I, running in 19ms.

  • Difficulty: Easy
  • Python
  • Runtime 19ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 19ms, memory 17.3MB, accepted 2026-01-01.

python
class Solution:
    def kthCharacter(self, k: int) -> str:
        word = "a"
        while len(word) < k:
            # Generate next string by shifting each character
            next_part = ""
            for c in word:
                # Shift to next character (wrap z to a)
                next_char = chr((ord(c) - ord('a') + 1) % 26 + ord('a'))
                next_part += next_char
            word = word + next_part
        return word[k - 1]

Source