Given an n x n two-dimensional array matrix, rotate the matrix 90 degrees clockwise in-place. This means the input two-dimensional matrix should be modified directly without using any additional 2D matrices.
matrix: number[][]: A 2D array matrix of size n x nInput: matrix = [[1,4],[2,6]]Output: [[2,1],[6,4]]Explanation: The 2x2 matrix is rotated 90 degrees clockwise.
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]Output: [[7,4,1],[8,5,2],[9,6,3]]Explanation: The 3x3 matrix is rotated 90 degrees clockwise.
Input: matrix = [[3]]Output: [[3]]Explanation: The 1x1 matrix remains the same after rotation.
n = matrix.length = matrix[i].lengthn <= 20matrix[row][col] <= 1000console.log() statements will appear here.