Created
March 31, 2018 06:03
-
-
Save 1nsunym/1cc8075a230f82648f74114071e8f829 to your computer and use it in GitHub Desktop.
LeetCode problem solutions: 771. Jewels and Stones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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