Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
385 B
8
Indexable
Never
class Solution {
public:
    int numJewelsInStones(string jewels, string stones) {
        
        unordered_map<char,int> m;
        for(int i=0; i<stones.size();++i)
        {
            m[stones[i]]++;
        }
        int sum{};
        for(int i=0; i<jewels.size();++i)
        {
            sum+=m[jewels[i]];
        }

        return sum;
        
    }
};
Leave a Comment