diff --git a/0771-jewels-and-stones/0771-jewels-and-stones.java b/0771-jewels-and-stones/0771-jewels-and-stones.java new file mode 100644 index 0000000..d892271 --- /dev/null +++ b/0771-jewels-and-stones/0771-jewels-and-stones.java @@ -0,0 +1,15 @@ +class Solution { + public int numJewelsInStones(String jewels, String stones) { + HashSet jewel = new HashSet<>(); + for (Character ch : jewels.toCharArray()) { + jewel.add(ch); + } + + int ans = 0; + for (Character ch : stones.toCharArray()) { + if (jewel.contains(ch)) ans++; + } + + return ans; + } +} \ No newline at end of file