LeetCodeAnimation/0771-Jewels-Stones/Code/1.java
2020-04-21 20:09:10 +08:00

14 lines
338 B
Java

class Solution {
public int numJewelsInStones(String J, String S) {
Set<Character> Jset = new HashSet();
for (char j: J.toCharArray())
Jset.add(j);
int ans = 0;
for (char s: S.toCharArray())
if (Jset.contains(s))
ans++;
return ans;
}
}