【Leetcode_easy】771. Jewels and Stones

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;

原文地址:https://www.cnblogs.com/happyamyhope/p/11202582.html