3304. Find the K-th Character in String Game I Easy
1/**
2 * [3304] Find the K-th Character in String Game I
3 *
4 * Alice and Bob are playing a game. Initially, Alice has a string word = "a".
5 * You are given a positive integer k.
6 * Now Bob will ask Alice to perform the following operation forever:
7 *
8 * Generate a new string by changing each character in word to its next character in the English alphabet, and append it to the original word.
9 *
10 * For example, performing the operation on "c" generates "cd" and performing the operation on "zb" generates "zbac".
11 * Return the value of the k^th character in word, after enough operations have been done for word to have at least k characters.
12 * Note that the character 'z' can be changed to 'a' in the operation.
13 *
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">k = 5</span>
17 * Output: <span class="example-io">"b"</span>
18 * Explanation:
19 * Initially, word = "a". We need to do the operation three times:
20 *
21 * Generated string is "b", word becomes "ab".
22 * Generated string is "bc", word becomes "abbc".
23 * Generated string is "bccd", word becomes "abbcbccd".
24 * </div>
25 * <strong class="example">Example 2:
26 * <div class="example-block">
27 * Input: <span class="example-io">k = 10</span>
28 * Output: <span class="example-io">"c"</span>
29 * </div>
30 *
31 * Constraints:
32 *
33 * 1 <= k <= 500
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/
39// discuss: https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn kth_character(k: i32) -> char {
45 '0'
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_3304() {
57 }
58}
59
Back
© 2025 bowen.ge All Rights Reserved.