Python Web 开发进阶实战:无障碍深度集成 —— 构建真正包容的 Flask + Vue 应用
2026/1/16 11:11:14
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; } };