<qiyuangong>784_Letter_Case_Permutation_1.java
public List<String> letterCasePermutation(String S) {
        List<StringBuilder> ans = new ArrayList();
        ans.add(new StringBuilder());

        for (char c: S.toCharArray()) {
            int n = ans.size();
            if (Character.isLetter(c)) {
                for (int i = 0; i < n; ++i) {
                    ans.add(new StringBuilder(ans.get(i)));
                    ans.get(i).append(Character.toLowerCase(c));
                    ans.get(n + i).append(Character.toUpperCase(c));
                }
            } else {
                for (int i = 0; i < n; ++i)
                    ans.get(i).append(c);
            }
        }

        List<String> finalans = new ArrayList();
        for (StringBuilder sb: ans)
            finalans.add(sb.toString());
        return finalans;
    }
public List < String > var_1 ( String var_2 ) {
  List < StringBuilder > var_6 = new ArrayList ( ) ;
  var_6 . add ( new StringBuilder ( ) ) ;
  for ( char var_9 : var_2 . toCharArray ( ) ) {
    int var_11 = var_6 . size ( ) ;
    if ( Character . isLetter ( var_9 ) ) {
      for ( int var_15 = 0 ;
      var_15 < var_11 ;
      ++ var_15 ) {
        var_6 . add ( new StringBuilder ( var_6 . get ( var_15 ) ) ) ;
        var_6 . get ( var_15 ) . append ( Character . toLowerCase ( var_9 ) ) ;
        var_6 . get ( var_11 + var_15 ) . append ( Character . toUpperCase ( var_9 ) ) ;
      }
    }
    else {
      for ( int var_15 = 0 ;
      var_15 < var_11 ;
      ++ var_15 ) var_6 . get ( var_15 ) . append ( var_9 ) ;
    }
  }
  List < String > var_20 = new ArrayList ( ) ;
  for ( StringBuilder var_21 : var_6 ) var_20 . add ( var_21 . toString ( ) ) ;
  return var_20 ;
}
