class Solution(object):
def numJewelsInStones(self, J, S):
"""
:type J: str
:type S: str
:rtype: int
"""
if len(J) == 0 or len(S) == 0:
return 0
j_set = set(J)
ans = 0
for c in S:
if c in j_set:
ans += 1
return ans
Download Jewels and Stones.pyLeetcode 771 Jewels and Stones problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.