diff --git a/.commitmsg b/.commitmsg new file mode 100644 index 000000000000..c1f77aeefcdf --- /dev/null +++ b/.commitmsg @@ -0,0 +1 @@ +3120: AC.cpp (#1606) - AC,22.22%,57.14% + (en) \ No newline at end of file diff --git a/Codes/3120-count-the-number-of-special-characters-i.cpp b/Codes/3120-count-the-number-of-special-characters-i.cpp new file mode 100644 index 000000000000..3e11b811af36 --- /dev/null +++ b/Codes/3120-count-the-number-of-special-characters-i.cpp @@ -0,0 +1,29 @@ +/* + * @Author: LetMeFly + * @Date: 2026-05-26 23:50:43 + * @LastEditors: LetMeFly.xyz + * @LastEditTime: 2026-05-26 23:53:14 + */ +#ifdef _DEBUG +#include "_[1,2]toVector.h" +#endif + +class Solution { +public: + int numberOfSpecialChars(string word) { + bool lower[26] = {false}, upper[26] = {false}; + for (char c : word) { + if ('a' <= c && c <= 'z') { + lower[c - 'a'] = true; + } else { + upper[c - 'A'] = true; + } + } + + int ans = 0; + for (int i = 0; i < 26; i++) { + ans += lower[i] && upper[i]; + } + return ans; + } +}; diff --git a/README.md b/README.md index 7c4579cb50fd..b79dcdb87e00 100644 --- a/README.md +++ b/README.md @@ -1057,6 +1057,7 @@ |3110.字符串的分数|简单|题目地址|题解地址|CSDN题解|LeetCode题解| |3112.访问消失节点的最少时间|中等|题目地址|题解地址|CSDN题解|LeetCode题解| |3115.质数的最大距离|中等|题目地址|题解地址|CSDN题解|LeetCode题解| +|3120.统计特殊字母的数量I|简单|题目地址|题解地址|CSDN题解|LeetCode题解| |3127.构造相同颜色的正方形|简单|题目地址|题解地址|CSDN题解|LeetCode题解| |3131.找出与数组相加的整数I|简单|题目地址|题解地址|CSDN题解|LeetCode题解| |3132.找出与数组相加的整数II|中等|题目地址|题解地址|CSDN题解|LeetCode题解| diff --git "a/Solutions/LeetCode 3120.\347\273\237\350\256\241\347\211\271\346\256\212\345\255\227\346\257\215\347\232\204\346\225\260\351\207\217I.md" "b/Solutions/LeetCode 3120.\347\273\237\350\256\241\347\211\271\346\256\212\345\255\227\346\257\215\347\232\204\346\225\260\351\207\217I.md" new file mode 100644 index 000000000000..3a3945deee19 --- /dev/null +++ "b/Solutions/LeetCode 3120.\347\273\237\350\256\241\347\211\271\346\256\212\345\255\227\346\257\215\347\232\204\346\225\260\351\207\217I.md" @@ -0,0 +1,105 @@ +--- +title: 3120.统计特殊字母的数量 I:(手写)哈希表 +date: 2026-05-26 23:55:19 +tags: [题解, LeetCode, 简单, 哈希表, set, 字符串] +categories: [题解, LeetCode] +--- + +# 【LetMeFly】3120.统计特殊字母的数量 I:(手写)哈希表 + +力扣题目链接:[https://leetcode.cn/problems/count-the-number-of-special-characters-i/](https://leetcode.cn/problems/count-the-number-of-special-characters-i/) + +
给你一个字符串 word。如果 word 中同时存在某个字母的小写形式和大写形式,则称这个字母为 特殊字母 。
返回 word 中 特殊字母 的数量。
+ +
示例 1:
+ +输入:word = "aaAbcBC"
+ +输出:3
+ +解释:
+ +word 中的特殊字母是 'a'、'b' 和 'c'。
示例 2:
+ +输入:word = "abc"
+ +输出:0
+ +解释:
+ +word 中不存在大小写形式同时出现的字母。
示例 3:
+ +输入:word = "abBCab"
+ +输出:1
+ +解释:
+ +word 中唯一的特殊字母是 'b'。
+ +
提示:
+ +1 <= word.length <= 50word 仅由小写和大写英文字母组成。