此篇文章為我的解題紀錄,程式碼或許並不是很完善

Leetcode - 771. Jewels and Stones

解題思路

跑迴圈用jewels裡的每一個字元算他出現在stones裡面幾次

我滴程式碼

1
2
3
4
5
6
class Solution:
def numJewelsInStones(self, jewels: str, stones: str) -> int:
count = 0
for ch in jewels:
count = count + stones.count(ch)
return count