Epicor Software interview question

Write code to rotate a given NxM matrix by 90 degrees.