#include
using namespace std;
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<n-i;j++){
cout<<"*";
}
for(int j=0;i<2*n-1;j++){
cout<<" ";
}
int n2=n-i;
if(i==0){n2--;}
for(int j=0;j<n2;j++){
cout<<"*";
}
cout<<endl;
}
for(int i=n-2;i<=0;i--){
for(int j=0;j<n-1;j++){
cout<<"*";
}
for(int j=0;j<(2*n)-1;j++){
cout<<" ";
}
int n2=n-i;
if(i==0)n2--;
for(int j=0;j<n2;j++)cout<<"*";
cout<<endl;
}
return 0;
}
While compiling my code , the time limit is exceeding