-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALPHABET.cpp
More file actions
54 lines (50 loc) · 848 Bytes
/
Copy pathALPHABET.cpp
File metadata and controls
54 lines (50 loc) · 848 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
54
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>
using namespace std;
bool check(int a[],int b[],int x)
{
for(int i=0;i<x;i++)
{
if(b[i]>a[i])
{
return false;
}
}
return true;
}
int main()
{
string a;
cin>>a;
int freqA[26]={0};
int x=26;
for(int i=0;i<a.length();i++)
{
freqA[a[i]-'a']++;
}
int t;
cin>>t;
while(t--)
{
string b;
cin>>b;
int freqB[26]={0};
for(int i=0;i<b.length();i++)
{
freqB[b[i]-'a']++;
if(freqB[b[i]-'a']>1)
{
freqB[b[i]-'a']=1;
}
}
if(check(freqA,freqB,x))
{
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
return 0;
}