:type J: str :type S: str :rtype: int
(self, J, S)
| 24 | |
| 25 | class Solution(object): |
| 26 | def numJewelsInStones(self, J, S): |
| 27 | """ |
| 28 | :type J: str |
| 29 | :type S: str |
| 30 | :rtype: int |
| 31 | """ |
| 32 | S_dict = {i:S.count(i) for i in set(S)} |
| 33 | |
| 34 | return sum((S_dict.get(i, 0) for i in J)) |