Domanda di colloquio di Amazon

Given a matrix as a 2D array in Java, and a variable that is either -1 or 1, rotate the array counter-clockwise or clockwise depending on the variable's value.