My issue
for test Case 3
possible permutations
(1,2,3)
(1,3,2)
(2,3,1)
(3,2,1)
so why it is showing only 2;
My code
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9+7;
int main() {
// your code goes here
int t, n;
vector<long long int>fact(300000);
fact[0] = 1;
for(long long int i =1; i<300000; i++){
fact[i] = ((i%mod)*(fact[i-1]%mod))%mod;
}
cin>>t;
while(t--){
cin>>n;
for(int i =1;i<=n; i++){
cout<<(((fact[i])*(fact[n-(i-1)]))%mod)<<" ";
}
cout<<endl;
}
}
Problem Link: Sum of Max K Subarray Practice Coding Problem