Jewels and Stones LeetCode solution in Python
1class Solution:2def numJewelsInStones(self, jewels: str, stones: str) -> int:3# 1 : One line solution, My best runtime 38 with 13.9 MB4return sum(1 for k in stones if k in jewels)56# 2 : Traditional solution7x = 08for k in stones:9if k in jewels:10x += 111return x