public String getPermutation(int n, int k) {
        int[] muls = new int[10];
        boolean[] used = new boolean[10];
        muls[0] = 1;
        for(int i = 1; i < 10; i++) {
            muls[i] = muls[i-1] * i;
            used[i] = false;
        }
        
        String ans = "";
        k--;
        for(int i = n - 1; i >= 0; i--){
            int t = k / muls[i] + 1;
            k = k % muls[i];
            for(int j = 1; j <= n; j++){
                if(!used[j]) t--;
                if(t == 0){
                    ans += j;
                    used[j] = true;
                    break;
                }
            }
        }
        return ans;
    }