Sunday, February 14, 2021

Leetcode Everyday: 771. Jewels and Stones. Easy

1
2
3
4
5
6
7
8
9
10
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