mirror of
https://gitee.com/TheAlgorithms/LeetCodeAnimation.git
synced 2024-12-06 15:19:44 +08:00
14 lines
338 B
Java
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;
|
|
}
|
|
} |