class Solution {
public:
int nums[10];
string getPermutation(int n, int k) {
for (int i = 1; i <= n; i++)
{
nums[i - 1] = i;
}
for (int i = 1; i < k; i++)
{
next_permutation(nums, nums + n);
}
string s;
for (int i = 0; i < n; i++)
{
s += to_string(nums[i]);
}
return s;
}
};
直接用了next_permutation
还可以写回溯的