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?
Doubt with code/problem
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
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].