Description Title:
idea:
1, with a number of different types of hash table records stones
2, in the gem and find if there is recorded the number of
code show as below:
class Solution {
public:
int numJewelsInStones(string J, string S) {
map<char,int>cnt;
int result=0;
for(int i=0;i<S.size();i++){
cnt[S[i]]++;
}
for(int i=0;i<J.size();i++){
if(cnt[J[i]]>0)
result+=cnt[J[i]];
}
return result;
}
};