MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / Solution

Class Solution

LeetCode_problems/Permutation Sequence/Solution.cpp:23–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class Solution {
24public:
25 string getPermutation(int n, int k) {
26 vector<int > v;
27
28 fact[0]=1,fact[1]=1,fact[2]=2;// pre compute factorial
29 for(int i=3;i<=n;i++){
30 fact[i]=fact[i-1]*i;
31 }
32 c=0;
33 s="";
34 for(int i=1;i<=n;i++){ // insert the first permutation in sorted order
35 v.push_back(i);
36 }
37 calc(n,k,n-1,v);
38
39 return s;
40
41 }
42};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected