Re: [闲聊] 每日leetcode

楼主: sixB (6B)   2024-10-05 10:14:57
60.
又写一题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
作者: dont   2024-10-05 10:18:00
大师
作者: DJYOSHITAKA (Evans)   2024-10-05 11:02:00
看code就觉得好难 你是大师==

Links booklink

Contact Us: admin [ a t ] ucptt.com