Code is running right but at time of submitting it show error/wrong

import java.util.*;
public class Main {
public static void main(String args[]) {
int nst = 1;
int rows = 1;
int N=5;
while (rows <= N) {

        int val = 1;

        if (rows != 1) {
            val = rows - 1;
        }
        int cst = 1;
        while (cst <= nst) {

            if (cst == 1 || cst == nst)
                System.out.print(val);
            else
                System.out.print(0);
            cst++;

        }

        rows++;
        System.out.println();
        nst++;
    }



}

}

take input from the user…(the value of n)

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.

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.