原题目:https://leetcode-cn.com/problems/jewels-and-stones/
思路:
构造哈希表
代码:
class Solution {
public:
int numJewelsInStones(string J, string S) {
map<char,int> h;
for(char& c:J) h[c] = 1;
int sum = 0;
for(char& c:S){
sum += h[c];
}
return sum;
}
};