Easy to understand concise Java Solution


#1

int top=0,right=A-1,left=0,bottom=A-1;
int k=1;
int[][] table=new int[A][A];
while(k<A*A+1)
{
for(int i=left;i<=right;i++)
table[top][i]=k++;

        top++;
        
        for(int i=top;i<=bottom;i++)
        table[i][right]=k++;
        right--;
        for(int i=right;i>=left;i--)
        table[bottom][i]=k++;
        bottom--;
        for(int i=bottom;i>=top;i--)
        table[i][left]=k++;
        left++;
        
    }return table;