2810. Faulty Keyboard Easy
1/**
2 * [2810] Faulty Keyboard
3 *
4 * Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as expected.
5 * You are given a 0-indexed string s, and you type each character of s using your faulty keyboard.
6 * Return the final string that will be present on your laptop screen.
7 *
8 * <strong class="example">Example 1:
9 *
10 * Input: s = "string"
11 * Output: "rtsng"
12 * Explanation:
13 * After typing first character, the text on the screen is "s".
14 * After the second character, the text is "st".
15 * After the third character, the text is "str".
16 * Since the fourth character is an 'i', the text gets reversed and becomes "rts".
17 * After the fifth character, the text is "rtsn".
18 * After the sixth character, the text is "rtsng".
19 * Therefore, we return "rtsng".
20 *
21 * <strong class="example">Example 2:
22 *
23 * Input: s = "poiinter"
24 * Output: "ponter"
25 * Explanation:
26 * After the first character, the text on the screen is "p".
27 * After the second character, the text is "po".
28 * Since the third character you type is an 'i', the text gets reversed and becomes "op".
29 * Since the fourth character you type is an 'i', the text gets reversed and becomes "po".
30 * After the fifth character, the text is "pon".
31 * After the sixth character, the text is "pont".
32 * After the seventh character, the text is "ponte".
33 * After the eighth character, the text is "ponter".
34 * Therefore, we return "ponter".
35 *
36 * Constraints:
37 *
38 * 1 <= s.length <= 100
39 * s consists of lowercase English letters.
40 * s[0] != 'i'
41 *
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/faulty-keyboard/
46// discuss: https://leetcode.com/problems/faulty-keyboard/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51 pub fn final_string(s: String) -> 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_2810() {
64 }
65}
66
Back
© 2025 bowen.ge All Rights Reserved.