Skip to content

Commit

Permalink
Time: 1 ms (55.88%), Space: 41.7 MB (62.61%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-S-Sahu committed Oct 23, 2024
1 parent 4fe81a7 commit 67b6a4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 0771-jewels-and-stones/0771-jewels-and-stones.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int numJewelsInStones(String jewels, String stones) {
HashSet<Character> 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;
}
}

0 comments on commit 67b6a4d

Please sign in to comment.