#include<bits/stdc++.h>
using namespace std;
#define INT_MAX 100007
string find_ans(string s,string p)
{
int sl=s.length();
int pl=p.length();
if(pl>sl)
{
return “No String”;
}
int fs[256]={0};
int fp[256]={0};
// forming the pattern array with index
for(int i=0;i<pl;i++)
{
char ch=p[i];
fp[ch]++;
}
int cnt=0;
int start=0;
int min_len=INT_MAX;
int start_idx=-1;
for(int i=0;i<sl;i++)
{
char ch=s[i];
fs[ch]++;
if(fp[ch]!=0 and fs[ch]<=fp[ch])
{
cnt++;
}
if(cnt==pl)
{
// now you are ready to shrink the array
char temp=s[start];
// matlab pattern mn nahin hai sirf fs mn h
while(fp[temp]==0 or fs[temp]>fp[temp])
{
fs[temp]–;
start++;
temp=s[start];
}
int window_len=i-start+1;
if(window_len < min_len)
{
min_len=window_len;
start_idx=start;
}
}
}
if(start_idx==-1)
{
return "No String";
}
string ans=s.substr(start_idx,min_len);
return ans;
}
int main()
{
string s,p;
getline(cin,s);
getline(cin,p);
cout<<s<<" "<<p<<endl;
cout<<find_ans(s,p)<<endl;
}
//string s;
//cin>>s;
//cout<<s;
//// snnsdfey kuft input
////output is snnsdfey
//but i want the output as
//// snnsdfey kuft