-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTONES.cpp
More file actions
53 lines (53 loc) · 754 Bytes
/
STONES.cpp
File metadata and controls
53 lines (53 loc) · 754 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t,i;
string je,s;
for(cin>>t;t--;)
{
cin>>je>>s;
int jj=je.length();
int ss=s.length();
int count=0;
int s1[52]={0},s2[52]={0};
int i;
for(i=0;i<jj;++i)
{
if(islower(je[i]))
{
int t=(int)(je[i]-97);
++s1[t];
}
else
{
int t=(int)(je[i]-65+26);
++s1[t];
}
}
for(i=0;i<ss;++i)
{
if(islower(s[i]))
{
int t=(int)(s[i]-97);
++s2[t];
}
else
{
int t=(int)(s[i]-65+26);
++s2[t];
}
}
for(i=0;i<52;++i)
{
//cout<<i<<" "<<s1[i]<<" "<<s2[i]<<"\n";
if(s1[i]!=0 and s2[i]!=0)
count+=s2[i];
}
cout<<count<<"\n";
}
return 0;
}