I've puzzled over this not usual task for a days to figure out an appropriate algorithm. Let's say I have 2D array:

```
int[][] jagged = new int[4][];
jagged[0] = new int[4] { 1, 2, 3, 4 };
jagged[1] = new int[4] { 5, 6, 7, 8 };
jagged[2] = new int[4] { 9, 10, 11, 12 };
jagged[3] = new int[4] { 13, 14, 15, 16 };

```

How can I rotate this matrix in counter-clockwise direction to be like the following?

```
1  2  3  4             2 3 4 8           3 4 8 12
5  6  7  8    -->      1 7 11 12   -->   2 11 10 16 
9  10 11 12            5 6 10 16         1 7  6  15 
13 14 15 16            9 13 14 15        5 9  13 14

```

**2D array can have various dimensions. I mean 2x3, or 3x4.**

I've tried to use the following algorithm, but it rotates just to 90 degrees:

```
int [,] newArray = new int[4,4];

for (int i=3;i>=0;--i)
{
    for (int j=0;j<4;++j)
    {
         newArray[j,3-i] = array[i,j];
    }
}

```

If I change increments, then it does give me nothing. Maybe is there another solution?