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