C++ | Hash-map | Clean and readable
Intuition:\n1) Store frequency of characters.\n2) Start making a resultant string where in if we see that incoming character is smaller than the already added l
**Intuition:**\n1) Store frequency of characters.\n2) Start making a resultant string where in if we see that incoming character is smaller than the already added last one then we pop the last character in resultant string if there we can get them later.\n\n```\nclass Solution {\npublic:\n    string smallestSubsequence(string text) {\n        int n = text.length();\n        \n        unordered_map<char, int>hm;\n        for (int i = 0; i < n; i++)\n            hm[text[i]]++;\n        \n        unordered_map<char, bool>seen;\n        string res;\n        \n        for (int i = 0; i < n; i++) {\n            hm[text[i]]--;\n            if (seen[text[i]]) continue;\n            seen[text[i]] = true;\n            \n            while(!res.empty() && res.back() > text[i] && hm[res.back()] > 0) {\n                seen[res.back()] = false;\n                res.pop_back();\n            }\n            \n            res.push_back(text[i]);\n        }\n        \n        return res;\n    }\n};\n```
[]