771. Jewels and Stones

 

 

class Solution {
public:
    int numJewelsInStones(string J, string S) {
        vector<int> container(256,0); 
        for(char s : S)
            container[s - '0']++;
        int count = 0;
        for(char j : J)
            count += container[j - '0'];
        return count;
    }
};

 

posted @ 2019-03-07 18:22  有梦就要去实现他  阅读(76)  评论(0编辑  收藏  举报