Find permutation of a specified lexicographic rank
This is nicely written, readable and efficient.



The most significant improvement I can suggest is to rewrite this as a for loop:


int index = 0;
while (index &lt; result.length) {
    result[index] = (int) (rank / factorial(digits - 1));
    rank %= factorial(digits - 1);
    index++;
    digits--;
}



Because this is essentially a counting loop, and index is not needed outside of it anyway. That is:

for (int index = 0; index &lt; result.length; ++index) {
    result[index] = (int) (rank / factorial(digits - 1));
    rank %= factorial(digits - 1);
    digits--;
}




It's recommended to declare variables using their interfaces, so instead of:


private static ArrayList&lt;Long&gt; factorialList = new ArrayList&lt;Long&gt;(Arrays.asList(1L,1L));



This is better:

private static List&lt;Long&gt; factorialList = new ArrayList&lt;&gt;(Arrays.asList(1L, 1L));




Lastly, a couple of nitpicks:


In lexicographicPermutation, int result[] = {-1} is a redundant local variable
It's recommended to use braces with single-statement if too
There are some redundant parentheses here and there, for example if ((rank &lt; 1) || ...)