How to print the result in diamond like this below? [duplicate]

Look i am not sure about the exact coding, but the way of doing these diamond problem is as follows:

Use two loops. One inside another. Outer loop will be for rows and inner loop for columns. Insert space for middle rows.

for (int i;i<rows.length;i++)
{ 
   for (int j;j<columns.length;j++)
   { 
      //your logic here to check where to insert space to make it diamond 
   } 
}

Leave a Comment