<awangdev>Remove Duplicate Letters_1.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]++;
        }

        StringBuffer sb = new StringBuffer("0");
        for (char c : arr) {
            count[c]--;
            if (visited[c]) {
                continue;
            }
            char lastChar = sb.charAt(sb.length() - 1);
            while (c < lastChar && count[lastChar] > 0) {
                sb.deleteCharAt(sb.length() - 1);
                visited[lastChar] = false;
                lastChar = sb.charAt(sb.length() - 1);
            }
            sb.append((char)(c));
            visited[c] = true;
        }

        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 ] ++ ;
  }
  StringBuffer var_15 = new StringBuffer ( "0" ) ;
  for ( char var_12 : var_7 ) {
    var_9 [ var_12 ] -- ;
    if ( var_11 [ var_12 ] ) {
      continue ;
    }
    char var_17 = var_15 . charAt ( var_15 . length ( ) - 1 ) ;
    while ( var_12 < var_17 && var_9 [ var_17 ] > 0 ) {
      var_15 . deleteCharAt ( var_15 . length ( ) - 1 ) ;
      var_11 [ var_17 ] = false ;
      var_17 = var_15 . charAt ( var_15 . length ( ) - 1 ) ;
    }
    var_15 . append ( ( char ) ( var_12 ) ) ;
    var_11 [ var_12 ] = true ;
  }
  return var_15 . substring ( 1 ) . toString ( ) ;
}
