链接:
题意:
简单题,不多说
解:
简单题,不多说
实际代码:
#include<bits/stdc++.h>
using namespace std;
int numJewelsInStones(string jewels, string stones)
{
set<char>chset;int ans=0;
for(auto &ch:jewels) chset.insert(ch);
for(auto &ch:stones) if(chset.count(ch)) ans++;
return ans;
}
int main()
{
string jewels,stones;
cin>>jewels>>stones;
int ans=numJewelsInStones(jewels,stones);
cout<<ans<<endl;
return 0;
}
限制:
1 <= jewels.length, stones.length <= 50
jewels 和 stones 仅由英文字母组成
jewels 中的所有字符都是 唯一的