Jewels and Stones LeetCode solution in Python

1
class Solution:
2
def numJewelsInStones(self, jewels: str, stones: str) -> int:
3
# 1 : One line solution, My best runtime 38 with 13.9 MB
4
return sum(1 for k in stones if k in jewels)
5

6
# 2 : Traditional solution
7
x = 0
8
for k in stones:
9
if k in jewels:
10
x += 1
11
return x

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0