Skip to content

Instantly share code, notes, and snippets.

@1nsunym
Created March 31, 2018 06:03
Show Gist options
  • Save 1nsunym/1cc8075a230f82648f74114071e8f829 to your computer and use it in GitHub Desktop.
Save 1nsunym/1cc8075a230f82648f74114071e8f829 to your computer and use it in GitHub Desktop.
LeetCode problem solutions: 771. Jewels and Stones
class Solution {
public:
int numJewelsInStones(string J, string S) {
bool isJewel[500] = {false, };
int jewelCount = 0;
for (int i = 0; i < J.length(); i++) {
isJewel[J[i]] = true;
}
for (int i = 0; i < S.length(); i++) {
jewelCount += int(isJewel[S[i]]);
}
return jewelCount;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment