For this Question: For a number N we have N! unique permutations. <b>A permutation is a sequence of integers from 1 to N of length N containing each number exactly once.</b>
For a positive integer X, <b>X! = 1 * 2 * 3 *...* X-1 * X</b>
Your task is to find the Kth smallest permutation when all possible permutations of size N are arranged in sorted order.Input contains only two integers, the value of N and K.

Constraints:-
1 <= N <= 10000
1 <= K <= min(N!,100000000)Print the Kth permutation in form of a string. i. e don't print spaces between two numbers.Sample Input:-
3 5

Sample Output:-
312

Explanation:-
All permutations of length 3 are:-
123
132
213
231
312
321

Sample Input:-
11 2

Sample Output:-
1234567891110, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s[]=br.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int k=Integer.parseInt(s[1]);
		Main m=new Main();
		System.out.print(m.getPermutation(n,k));
	}
	public String getPermutation(int n, int k) {
        int idx = 1;
        for (  idx = 1; idx <= n;idx++) {
            if (fact(idx) >= k) break;
        }
        StringBuilder ans = new StringBuilder();
        for( int i = 1; i <=n-idx;i++) {
            ans.append(i);
        }

        ArrayList<Integer> dat = new ArrayList<>(n);
	    for( int i = 1; i <= idx;i++) {
	        dat.add(i);
	    }

        for( int i = 1; i <= idx;i++) {
            int t = (int) ((k-1)/fact(idx-i));
            ans.append(dat.get(t)+(n-idx));
            dat.remove(t);
            k = (int)(k-t*(fact(idx-i)));

        }

        return ans.toString();

    }
	public String getPermutation0(int n, int k) {
	    int idx = k;
	    StringBuilder ans = new StringBuilder();

	    ArrayList<Integer> dat = new ArrayList<>(n);
	    for( int i = 1; i <= n;i++) {
	        dat.add(i);

	    }


	    for(int i = 1; i <= n;i++) {
	        idx = (int)((k-1)/fact(n-i));
	        ans.append(dat.get(idx));
	        dat.remove(idx);
	        k = (int)(k - idx*fact(n-i));

	    }
	    return ans.toString();
	}

	public long fact(int n) {
	    int f = 1;
	    for( int i = 1; i <= n;i++) {
	        f *= i;
	    }
	    return f;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?