<awangdev>Permutation Index_1.java
public long permutationIndex(int[] A) {
    	if (A == null || A.length == 0) {
    		return 0;
    	}
    	HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    	int n = A.length;
    	long rst = 0;
    	for (int i = 0; i < n; i++) {
    	    int count = 0;
    		for (int j = i + 1; j < n; j++) {
    			if (A[j] < A[i]) {
    				count++;
    			}
    		}
    		map.put(A[i], count);
    	}
    	for (int i = 0; i < n; i++) {
    		long fact = 1;
    		for (int j = (n - i - 1); j >= 1; j--) {
    			fact *= j;
    		}
    		rst += map.get(A[i]) * fact;
    	}
    	return rst + 1;
    }
public long sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 ) {
    return 0 ;
  }
  HashMap < Integer , Integer > var_6 = new HashMap < Integer , Integer > ( ) ;
  int var_7 = var_0 . length ;
  long var_8 = 0 ;
  for ( int var_9 = 0 ;
  var_9 < var_7 ;
  var_9 ++ ) {
    int var_10 = 0 ;
    for ( int var_12 = var_9 + 1 ;
    var_12 < var_7 ;
    var_12 ++ ) {
      if ( var_0 [ var_12 ] < var_0 [ var_9 ] ) {
        var_10 ++ ;
      }
    }
    var_6 . put ( var_0 [ var_9 ] , var_10 ) ;
  }
  for ( int var_9 = 0 ;
  var_9 < var_7 ;
  var_9 ++ ) {
    long var_14 = 1 ;
    for ( int var_12 = ( var_7 - var_9 - 1 ) ;
    var_12 >= 1 ;
    var_12 -- ) {
      var_14 *= var_12 ;
    }
    var_8 += var_6 . get ( var_0 [ var_9 ] ) * var_14 ;
  }
  return var_8 + 1 ;
}
