作者:
sixB (6B)
2024-10-05 10:14:5760.
又寫一題permutation
雖然概念完全不一樣就是了==
排列組合
找n! 裡的第k個
一位一位找 看是要第幾個
然後就下面一位
阿信都會
class Solution {
public:
string getPermutation(int n, int k) {
vector<int> s(n+1, 1);
int total = 1;
for(int i = 1; i <= n; i++){
total *= i;
}
string res;
while(n > 0){
int div = total / n;
int pos = (k-1)/div + 1;
int idx = 1;
for(int i = pos; i > 1; idx++){
if(s[idx] > 0){
i