You are viewing a single comment's thread. Return to all comments →
vector<int> absolutePermutation(int n, int k) { vector<int>arr,brr; for(int i=1;i<=n;i++) arr.push_back(i); if(k==0) return arr; if(n%(2*k)==0){ for(int i=0;i<n/(2*k);i++){ for(int j=1;j<=k;j++) brr.push_back((2*k*i)+k+j); for(int j=1;j<=k;j++){ brr.push_back(2*k*i+j); } } } if(brr.size()==0) return {-1}; return brr; }
Absolute Permutation
You are viewing a single comment's thread. Return to all comments →