Pattern double sided arrow testcases

code is working for n=7 but for any other value it is showing wrong answer plzz help.https://ide.codingblocks.com/s/63284

Hii Himanshu,
There is a logic error. You can see my code:
https://ide.codingblocks.com/s/63305

hey sanyam thanks for the code but can u plzz explain in line no 9 why have u initialized nsp=2*n-2; as for n=7 value of nsp will be 12 but i cant find any place in the pattern where there are 12 spaces.

I keep nsp= 2*n - 2 because see for n = 7 and when row is 1, nsp = 12 as there are 6 spaces for digits and 6 spaces for the space between the digits.

can any one explain how this loop is working in pattern DoubleSideArrow
int cst = 1;
val++ ;
if (row == 1 || row == n) {
cst = 2;

        }