终极键盘快捷键定制指南:3倍提升浏览器操作效率
2025/12/23 10:05:07
Problem: 771. Jewels and Stones 宝石与石头
耗时100%,不用哈希表map比较慢,直接用数组,ASCII小于255,所以只需要200的数组即可,记录以后统计即可
class Solution { public: bool ch[200]; int numJewelsInStones(string jewels, string stones) { memset(ch, 0, sizeof(ch)); for(char& c : jewels) { ch[(int)c] = true; } int num = 0; for(char& c : stones) { if(ch[(int)c] == true) { num++; } } return num; } };