https://leetcode.com/problems/jewels-and-stones/

Source


    int numJewelsInStones(string jewels, string stones) {
        int cnt = 0;
        int prev = 0, pos;
        while ((pos=stones.find_first_of(jewels, prev)) != string::npos) {
            cnt++;
            prev = pos + 1;
        }
        return cnt;
    }

GitHub

JewelsStones