Posted on

Description

Submission

class Solution {
public:
    int numJewelsInStones(string J, string S) {
        map<char, int> m;

        for(char ch: J) {
            m[ch]++;
        }

        int ret = 0;
        for(char ch: S) {
            if(m.find(ch) != m.end()) {
                ret++;
            }
        }
        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *