We have a n\*n matrix for example we take n=4 and the matrix is given below.

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

```

We have to traverse it in the sequence:

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

```

How can I do this?