-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAnagram_Search.cpp
More file actions
39 lines (39 loc) · 875 Bytes
/
Anagram_Search.cpp
File metadata and controls
39 lines (39 loc) · 875 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
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define ff first
#define ss second
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define setbits(x) __builtin_popcountll(x)
#define inf 1e18
#define sfp(x,y) fixed<<setprecision(x)<<y
#define mod 1000000007
int main()
{
fast;
string a,b;cin>>a>>b;
int c[500]{0},d[500]{0};
int n=a.size(),m=b.size();
fo(i,m)
{
d[b[i]-'a']++;
}
int ans=0;
fo(i,n){
if(a[i]!='?')c[a[i]-'a']++;
if(i>=m && (a[i-m]!='?'))c[a[i-m]-'a']--;
if(i+1>=m)
{
bool f=true;
fo(j,26)
{
if(c[j]>d[j])f=false;
}
if(f==true)ans++;
}
}
cout<<ans;
return 0;
}