Why is my code giving TLE error?

no of starts can be written as 2(n-i) -1
so you can change the star loop to:

for(int k=1;k<(2*(n-i));k++){
	System.out.print("* ");
} 

here is your corrected code:


if this solves your dooubt please mark it as resolved