Leetcode 771. Jewels and Stones

class Solution(object):
    def numJewelsInStones(self, J, S):
        """
        :type J: str
        :type S: str
        :rtype: int
        """
        count=collections.Counter(S)
        ans=0
        for j in J:
            ans+=count.get(j,0)
        return ans

 

posted @ 2019-03-20 07:50  周洋  阅读(84)  评论(0编辑  收藏  举报