Error for time limit

#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

hi @yashtripathi6969_0cd127807d833066,
The given pattern is seen as first stars then spaces and then stars .So for each row do the work of stars fist , then that of spaces and then that of stars. And then change the variables accordingly for next iterations…

refer this code -->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.