Doubt with code/problem

My code is running perfectly fine with my compiler, and also the same test case comes with N=4. Then what problem am i facing?

These are changes in your code:


Works fine now.

1 Like

thanks for the help, but can you tell me the significance of (-2) used in the first inner loop. Does the IDE also sensitive to extra spaces?
I am bit confused with the maths played over here, like in the 0th row, it is 5-2=3 spaces, then 2 spaces in the 1st row, 1 in the 2nd row, 0 in the 3rd row, then it will move to -1 spaces in the 4th row. That’s my doubt that how negative spaces can be confronted in code, it will surely print 0 spaces as well.
However, even if we replace this spaces with β€˜tab’, the output is same. Over here u have fixed it using double space. using tab also, I am getting the same output, but there also how the first loop is giving output.(j<=N-i-2)

Consider n=3
image
If you see the pattern, it clearly need n-1-i tabs before every line (i iterates from 0–>n-1).
for loop goes from (j=1; j<=n-i-1; j++) , j=[1–>n-1-i].
If you start from j=0, then it goes from (j=0; j<=n-i-2; j++) , j=[0–>n-2-i].

hi @siddharthkumaree21b954_52c884d346b69187 is the doubt clear?