public String getPermutation(int n, int k) {
        int[] num = new int[n + 1];
        int count = 1;
        for(int i = 0; i < n; i++){
            num[i] = i + 1;
            count *= i + 1;
        }
        k--;
        StringBuilder result = new StringBuilder();
        for(int i = 0; i < n; i++){
            count /= n - i;
            int index = k/count;
            result.append(num[index]);
            for(int j = index; j < n; j++){
                num[j] = num[j + 1];
            }
            k %= count;
        }
        return result.toString();
    }