Sunday, February 14, 2021

Leetcode Everyday: 771. Jewels and Stones. Easy

public class Solution {
    public int NumJewelsInStones(string jewels, string stones) {
        var list = 
            from stone in stones
            where jewels.Any(jewel => stone == jewel)
            select stone;
        
        return list.Count();
    }
}

Source: https://leetcode.com/problems/jewels-and-stones/

No comments:

Post a Comment