Ques 20: pattern not ok

package PatternsQuestions;

import java.util.Scanner;

public class ques20 {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	
	// setting intial values
	int nst = 1;
	int nsp = n/2;
	int nspbw = 1; // defining space in between
	
	// setting for loop
	for(int row = 1; row<=n; row++) {
		
		
		for (int csp = 1; csp <= nsp; csp++) {
			System.out.print(" ");
		}
		
		
		for(int cst=1; cst<=nst; cst++) {
			System.out.print("*");
		}
		
		int cst;
		if(row>=2 && row <n) {
			cst = row;
		} else {
			cst = n+1;
		}
		
		for(; cst <= row; cst++) {
			for(int cspw=1; cspw<= nspbw; cspw++) {
				System.out.print(" ");
			}
			
			for(int cst2=1; cst2<= nst; cst2++) {
				System.out.print("*");
			}
		}
		
		
		//preparation
		System.out.println();
		if(row < n/2) {
			nsp--;
			nspbw+=2;
		} else {
			nsp++;
			nspbw-=2;
		}
	}
	scn.close();

}

}

Request you to provide solution for this

@sinuscoupon0s_4659768f9d9b587e Look for the comments in the code I have mentioned and try to grasp what I have done.
Link :

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.