<awangdev>Remove Duplicate Letters_2.java
String removeDuplicateLetters(String s) {
        if (s == null || s.length() <= 1) {
            return s;
        }
        char[] arr = s.toCharArray();
        int[] count = new int[256];
        boolean[] visited = new boolean[256];
        for (char c : arr) {
            count[c]++;
        }

        Stack<Character> stack = new Stack<>();
        stack.push('0');
        for (char c : arr) {
            count[c]--;
            if (visited[c]) {
                continue;
            }
            while (c < stack.peek() && count[stack.peek()] > 0) {
                visited[stack.pop()] = false;
            }
            stack.push(c);
            visited[c] = true;
        }

        StringBuffer sb = new StringBuffer();
        while (!stack.isEmpty()) {
            sb.insert(0, stack.pop());
        }
        return sb.substring(1).toString();
    }
String var_0 ( String var_2 ) {
  if ( var_2 == null || var_2 . length ( ) <= 1 ) {
    return var_2 ;
  }
  char [ ] var_7 = var_2 . toCharArray ( ) ;
  int [ ] var_9 = new int [ 256 ] ;
  boolean [ ] var_11 = new boolean [ 256 ] ;
  for ( char var_12 : var_7 ) {
    var_9 [ var_12 ] ++ ;
  }
  Stack < Character > var_15 = new Stack < > ( ) ;
  var_15 . push ( '0' ) ;
  for ( char var_12 : var_7 ) {
    var_9 [ var_12 ] -- ;
    if ( var_11 [ var_12 ] ) {
      continue ;
    }
    while ( var_12 < var_15 . peek ( ) && var_9 [ var_15 . peek ( ) ] > 0 ) {
      var_11 [ var_15 . pop ( ) ] = false ;
    }
    var_15 . push ( var_12 ) ;
    var_11 [ var_12 ] = true ;
  }
  StringBuffer var_21 = new StringBuffer ( ) ;
  while ( ! var_15 . isEmpty ( ) ) {
    var_21 . insert ( 0 , var_15 . pop ( ) ) ;
  }
  return var_21 . substring ( 1 ) . toString ( ) ;
}
