import java.util.*;
public class Solution {
public int numJewelsInStones (String jewels, String stones) {
HashMap<Character,Integer> map = new HashMap<>();
int ans = 0;
for(int i=0;i<jewels.length();i++){
map.put(jewels.charAt(i),1);
}
for(int i=0;i<stones.length();i++){
int cur = map.getOrDefault(stones.charAt(i),0);
ans += cur;
}
return ans;
}
}

京公网安备 11010502036488号