Jewels and Stones LeetCode solution in Java
1class Solution {2public int numJewelsInStones(String jewels, String stones) {3HashSet<Character> hs = new HashSet<>();4int count = 0;5for (int i = 0; i < jewels.length(); i++) {6hs.add(jewels.charAt(i));7}8for (int i = 0; i < stones.length(); i++) {9if (hs.contains(stones.charAt(i))) count++;10}11return count;12}13}