We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f67240 commit d7a6177Copy full SHA for d7a6177
30-days-of-code-may/02.jewelAndStones.cpp
@@ -0,0 +1,22 @@
1
+class Solution {
2
+public:
3
+ int numJewelsInStones(string J, string S) {
4
+ if(J.size() == 0 or S.size() == 0) return 0;
5
+
6
+ map<char, int> stones;
7
8
+ for(int i=0; i<S.size();i++){
9
+ if(stones.find(S[i]) == stones.end())
10
+ stones[S[i]] = 1;
11
+ else
12
+ stones[S[i]]++;
13
+ }
14
+ int c = 0;
15
+ for(char j:J){
16
+ if(stones.find(j) != stones.end()){
17
+ c+=stones[j];
18
19
20
+ return c;
21
22
+};
0 commit comments