3120. Count the Number of Special Characters I Easy
1/**
2 * [3120] Count the Number of Special Characters I
3 *
4 * You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word.
5 * Return the number of special letters in word.
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">word = "aaAbcBC"</span>
10 * Output: <span class="example-io">3</span>
11 * Explanation:
12 * The special characters in word are 'a', 'b', and 'c'.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">word = "abc"</span>
17 * Output: <span class="example-io">0</span>
18 * Explanation:
19 * No character in word appears in uppercase.
20 * </div>
21 * <strong class="example">Example 3:
22 * <div class="example-block">
23 * Input: <span class="example-io">word = "abBCab"</span>
24 * Output: 1
25 * Explanation:
26 * The only special character in word is 'b'.
27 * </div>
28 *
29 * Constraints:
30 *
31 * 1 <= word.length <= 50
32 * word consists of only lowercase and uppercase English letters.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/count-the-number-of-special-characters-i/
38// discuss: https://leetcode.com/problems/count-the-number-of-special-characters-i/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn number_of_special_chars(word: String) -> i32 {
44 0
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3120() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.