Rotating a matrix is a combination of 2 transformations:

  1. Reverse the rows.
  2. Diagnal flip. (Swap a[i][j] and a[j][i])