Leetcode 782 Solution
This article provides solution to leetcode question 782 (jewels-and-stones)
Access this page by simply typing in "lcs 782" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/jewels-and-stones
Solution
class Solution {
public:
int numJewelsInStones(string J, string S) {
unordered_set<char> jewels;
for (auto jewel: J)
jewels.insert(jewel);
int total = 0;
for (auto stone: S)
total += jewels.find(stone) != jewels.end();
return total;
}
};