what is the problem with the following code?
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
string s1,s2;
getline(cin,s1);
getline(cin,s2);
unordered_set r; //to store the characters of second string
string t,ans;
priority_queue<int,vector<int>,greater<int> >pos; /*to store the position of characters
found in string1 which were there in 2nd string.*/
unsigned int count=0;
int beg=0;
for(unsigned int i=0;i<s2.length();i++)
{
r.insert(s2[i]);
}
for(unsigned int i=0;i<s1.length();i++)
{
if(t.length()==0)
{
if(r.find(s1[i])!=r.end())
{
count++;
t+=s1[i];
if((pos.empty()==false&&pos.top()!=i)||pos.empty()==true)
pos.push(i);
}
}
else
{
t+=s1[i];
if(r.find(s1[i])!=r.end())
{
count++;
pos.push(i);
}
if(count==r.size())
{
//cout<<t<<" ";
if(ans.length()==0)
ans=t;
else if(ans.length()>t.length())
ans=t;
t="";
count=0;
if(pos.empty()==false)
{
i=pos.top();
pos.pop();
}
//cout<<i<<"\n";
}
}
}
if(ans.length()==0)
cout<<"No string";
else
cout<<ans;
return 0;
}
submission number 2912639