problem 771.Jewels and Stones solution1: class Solution { public: int numJewelsInStones(string J, string S) { int res = 0; unordered_setchar js(J.begin(), J.end()); for(auto ch:S) { if(js.find(ch)!=js.end()) res++; } return res;
problem
771. Jewels and Stones
solution1:
class Solution {public:
int numJewelsInStones(string J, string S) {
int res = 0;
unordered_set<char> js(J.begin(), J.end());
for(auto ch:S)
{
if(js.find(ch)!=js.end()) res++;
}
return res;
}
};
参考
1. Leetcode_easy_771. Jewels and Stones;
2. Grandyang;
完