beats 100% , idea is to think as per the frequency whether it can add to result or not
\nclass Solution {\npublic:\n    string smallestSubsequence(string s) {\n        vector<int> a(26,0);\n        \n        int u = 0;\n        for(auto i: s)\n   
```\nclass Solution {\npublic:\n    string smallestSubsequence(string s) {\n        vector<int> a(26,0);\n        \n        int u = 0;\n        for(auto i: s)\n        {\n            a[i-\'a\']++;\n            if(a[i-\'a\']==1)\n                u++;\n        }\n        \n        string ans = "";\n        map<char,bool> mp;\n\n        for(int i=0;i<s.length();i++)\n        {\n            \n            while(mp[s[i]]==false && ans.length()>0 && ans.back()>s[i] && a[ans.back()-\'a\']>=1)\n            {\n                mp[ans.back()]=false;   \n                ans.erase(ans.begin()+ans.size()-1);\n            }\n            \n            if(mp[s[i]]==false){\n                ans.push_back(s[i]);\n                mp[s[i]]=true;\n            }\n            a[s[i]-\'a\']--;\n        }\n        \n        \n        return ans;\n        \n    }\n};\n```
[]