2026年物业门控五金耗材推荐榜:中企创联工业品,小区/写字楼/物业多场景门控配件全覆盖
2026/3/1 13:31:04
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; } };