leetcode771

int numJewelsInStones(string J, string S) {
    set<char> st;
    int count = 0;
    for (auto c : J)
    {
        st.insert(c);
    }
    for (auto s : S)
    {
        if (st.find(s) != st.end())
        {
            count++;
        }
    }
    return count;
}
原文地址:https://www.cnblogs.com/asenyang/p/9712307.html