Jewels and Stones (Leetcode 771)

Problem Link: https://leetcode.com/problems/jewels-and-stones/

class Solution:
    def numJewelsInStones(self, jewels: str, stones: str) -> int:
        d={}
        for i in jewels:
            d[i]=1    
        c=0
        for i in stones:
            if(i in d):
                c+=1  
        return c

Last updated