public class Solution {
public static String getPermutation(int n, int k) {
k=k-1;
ArrayList<Character> digitals=new ArrayList<>(Arrays.asList('1','2','3','4','5','6','7','8','9'));
int fac=1;
int fon;
String tol="";
for(int i=1;i<n;i++)
{
fac=fac*i;
}
while(n!=0)
{
fon=k/fac;
tol=tol+digitals.get(fon);
digitals.remove(fon);
k=k%fac;
if(n==1) break;
fac=fac/--n;
}
return tol;
}
}