- jewels에서 for문을 돌며 각 문자열에 대한 갯수를 결과에 더해줌.
- Counter를 사용하면 각 문자에 대한 갯수를 확인할 수 있음.
from collections import Counter
class Solution:
def numJewelsInStones(self, jewels: str, stones: str) -> int:
res = 0
for j in jewels :
tmp = Counter(stones)[j]
res += tmp
return res