In Java, rotate a square matrix counter-clockwise or clockwise 90 degreesan arbitrary number of times. You will
Question:
In Java,
rotate a square matrix counter-clockwise or clockwise 90 degreesan arbitrary number of times. You will be given a matrix ofintegers (otherwise known as a 2-dimensional array), that has equalheight and width. The dimension can range from 2x2 - 10x10. Youwill also be given an integer that may range from -100 to 100, thisinteger will indicate which direction to rotate the matrix and howmany times to rotate it. You are expected to return the rotatedmatrix.
direction - The number of rotations in a particular direction.If > 0 rotate the specified amount of times clockwise. else if< 0 rotate the specified amount of times counterclockwise.Otherwise, no rotations are expected.
matrix - A two-dimensional array of integers that is to berotated.
returns - The rotated matrix it was initially given.
int[][] rotateMatix(int direction, int[][] matrix)
Statistics The Art And Science Of Learning From Data
ISBN: 9780321755940
3rd Edition
Authors: Alan Agresti, Christine A. Franklin