880. Decoded String at Index Medium

@problem@discussion
#String#Stack



1/**
2 * [880] Decoded String at Index
3 *
4 * You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:
5 * 
6 * 	If the character read is a letter, that letter is written onto the tape.
7 * 	If the character read is a digit d, the entire current tape is repeatedly written d - 1 more times in total.
8 * 
9 * Given an integer k, return the k^th letter (1-indexed) in the decoded string.
10 *  
11 * Example 1:
12 * 
13 * Input: s = "leet2code3", k = 10
14 * Output: "o"
15 * Explanation: The decoded string is "leetleetcodeleetleetcodeleetleetcode".
16 * The 10^th letter in the string is "o".
17 * 
18 * Example 2:
19 * 
20 * Input: s = "ha22", k = 5
21 * Output: "h"
22 * Explanation: The decoded string is "hahahaha".
23 * The 5^th letter is "h".
24 * 
25 * Example 3:
26 * 
27 * Input: s = "a2345678999999999999999", k = 1
28 * Output: "a"
29 * Explanation: The decoded string is "a" repeated 8301530446056247680 times.
30 * The 1^st letter is "a".
31 * 
32 *  
33 * Constraints:
34 * 
35 * 	2 <= s.length <= 100
36 * 	s consists of lowercase English letters and digits 2 through 9.
37 * 	s starts with a letter.
38 * 	1 <= k <= 10^9
39 * 	It is guaranteed that k is less than or equal to the length of the decoded string.
40 * 	The decoded string is guaranteed to have less than 2^63 letters.
41 * 
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/decoded-string-at-index/
46// discuss: https://leetcode.com/problems/decoded-string-at-index/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51    pub fn decode_at_index(s: String, k: i32) -> String {
52        String::new()
53    }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn test_880() {
64    }
65}
66


Back
© 2025 bowen.ge All Rights Reserved.