-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJewels_Stone.cpp
56 lines (41 loc) · 980 Bytes
/
Jewels_Stone.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<iostream>
#include<unordered_set>
#include<map>
using namespace std;
int main(){
string J ="evr";
string S ="fsdelqgvwn";
/*
int freq_stones[58] = {0};
int freq_jewels[58] = {0};
for(int i=0;i<S.size();i++)
freq_stones[S[i]-'A']++;
for(int i=0;i<J.size();i++)
freq_jewels[J[i]-'A']++;
int sum=0;
for(int i=0; i<58; i++){
if(freq_stones[i]!=0 && freq_jewels[i]!=0){
sum += freq_stones[i];
}
}
cout<<sum;
*/
/*
unordered_set<char> hs;
for(char x : J)
hs.insert(x);
int count=0;
for(int i=0;i<S.size();i++){
if(hs.find(S[i])!=hs.end()){
count++;
}
}
cout<<count;
*/
map<char,int>m;
for(auto it: S) m[it]++;
int ans = 0;
for(auto it: J) ans += m[it];
cout<<ans;
return 0;
}