import java.util.HashSet;
import java.util.Set;
//宝石和石头
//J中是宝石的类型,S是拥有的石头,求拥有多少个宝石
public class p3 {
public int numJewelsInStones(String J,String S){
Set<Character> jewels=new HashSet<>();
//把J转换成字符型数组,会返回一个字符型数组
for(char ch:J.toCharArray()){
jewels.add(ch);
}
int count=0;
for(char ch:S.toCharArray()){
if(jewels.contains(ch)){
count++;
}
}
return count;
}
}