MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / numJewelsInStones

Method numJewelsInStones

String/JewelsAndStones.py:26–34  ·  view source on GitHub ↗

:type J: str :type S: str :rtype: int

(self, J, S)

Source from the content-addressed store, hash-verified

24
25class 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))

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected