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;
}

 

posted on 2018-09-27 11:49  Sempron2800+  阅读(131)  评论(0编辑  收藏  举报