JS & TS simple solution using stack
This solution is based on this solution.\n\n\nfunction smallestSubsequence(s: string): string {\n    const stack = [];\n    \n    for (let i = 0; i < s.length; 
This solution is based on [this solution](http://leetcode.com/problems/remove-duplicate-letters/discuss/977608/Use-stack-to-solve-by-JS-94.89-fast-100-less-memory-with-explaination).\n\n```\nfunction smallestSubsequence(s: string): string {\n    const stack = [];\n    \n    for (let i = 0; i < s.length; i++) {\n        const char = s[i];\n        \n        if (stack.indexOf(char) > -1) continue;\n        \n        while (stack.length > 0 \n               && stack[stack.length - 1] > char \n               && s.indexOf(stack[stack.length - 1], i) > i) stack.pop();\n        \n        stack.push(char);\n    }\n    \n    return stack.join("");\n};\n```
['Stack', 'TypeScript', 'JavaScript']