大庆市网站建设_网站建设公司_测试上线_seo优化
2025/12/23 10:02:51 网站建设 项目流程

Problem: 771. Jewels and Stones 宝石与石头

解题过程

耗时100%,不用哈希表map比较慢,直接用数组,ASCII小于255,所以只需要200的数组即可,记录以后统计即可

Code

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; } };

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询