string removeDuplicateLetters(string s) {
int arr[126]={0};
int n=s.length();
for(int i=0;i<n;i++)
{
arr[s[i]]+=1;
}
stack<char>s1;
int i=1;
s1.push(s[0]);
while(i<s.length())
{
char ch=s[i];
while(s1.top()>ch and !s1.empty())
{
if( arr[s1.top()]>1)
{
s1.pop();
}
}
s1.push(s[i]);
i++;
}
string ans="";
while(!s1.empty())
{
ans=s1.top()+ans;
s1.pop();
}
return ans;
}