<awangdev>Permutation Sequence_2.java
public String getPermutation(int n, int k) {
        if (n <= 0 || k <= 0) {
        	return "";
        }
        ArrayList<Integer> nums = new ArrayList<Integer>();
        for (int i = 1; i <= n; i++) {
        	nums.add(i);
        }

        int frontInd = 0;
        for (; frontInd < nums.size(); frontInd++) {
	        int factorio = 1;
	    	for (int i = 1; i < n; i++) {
	    		factorio = factorio * i;
	    	}
	    	int startInd = frontInd;
	    	int numPermute = factorio;
	    	while (numPermute < k) {
	    		numPermute += factorio;
	    		startInd++;
	    	}

	    	if (startInd != frontInd) {
	    		int temp = nums.get(startInd);
	    		nums.remove(startInd);
	    		nums.add(frontInd, temp);
		  		k = k - numPermute;
		  		n--;
	        }
	    }
	    StringBuffer sb = new StringBuffer();
      	for (int num : nums) {
      		sb.append(num);
      	}
        return sb.toString();
    }
public String var_0 ( int var_1 , int var_2 ) {
  if ( var_1 <= 0 || var_2 <= 0 ) {
    return "" ;
  }
  ArrayList < Integer > var_7 = new ArrayList < Integer > ( ) ;
  for ( int var_9 = 1 ;
  var_9 <= var_1 ;
  var_9 ++ ) {
    var_7 . add ( var_9 ) ;
  }
  int var_11 = 0 ;
  for ( ;
  var_11 < var_7 . size ( ) ;
  var_11 ++ ) {
    int var_13 = 1 ;
    for ( int var_9 = 1 ;
    var_9 < var_1 ;
    var_9 ++ ) {
      var_13 = var_13 * var_9 ;
    }
    int var_14 = var_11 ;
    int var_15 = var_13 ;
    while ( var_15 < var_2 ) {
      var_15 += var_13 ;
      var_14 ++ ;
    }
    if ( var_14 != var_11 ) {
      int var_17 = var_7 . get ( var_14 ) ;
      var_7 . remove ( var_14 ) ;
      var_7 . add ( var_11 , var_17 ) ;
      var_2 = var_2 - var_15 ;
      var_1 -- ;
    }
  }
  StringBuffer var_20 = new StringBuffer ( ) ;
  for ( int var_21 : var_7 ) {
    var_20 . append ( var_21 ) ;
  }
  return var_20 . toString ( ) ;
}
