[java] [stack] [map] [4ms]
```\nclass Solution {\n    public String smallestSubsequence(String s) {\n    \n      Deque stack = new LinkedList<>();\n       Map freq = new HashMap<>();\n   
```\nclass Solution {\n    public String smallestSubsequence(String s) {\n    \n      Deque<Character> stack = new LinkedList<>();\n       Map<Character,Integer> freq = new HashMap<>();\n       for(char c : s.toCharArray())\n           freq.put(c,freq.getOrDefault(c,0)+1);\n\n       for(char c : s.toCharArray()){//abacb"\n           if(!stack.isEmpty() && stack.contains(c)) {\n               freq.put(c,freq.get(c)-1);\n               continue;\n           }\n           while (!stack.isEmpty() && c <= stack.peek()\n               && freq.get(stack.peek()) > 1){\n                   freq.put(stack.peek(),freq.get(stack.pop())-1);\n               }\n               stack.push(c);\n               }\n       StringBuilder stringBuilder = new StringBuilder();\n       while (!stack.isEmpty()){\n           stringBuilder.append(stack.pop());\n       }\n       return stringBuilder.reverse().toString();\n    }\n}\n    \n
['Stack', 'Java']