/**
* @param {number} n
* @return {number[][]}
*/vargenerateMatrix=function(n){var maxtrix =newArray(n).fill().map(item=>newArray(n))let num =1;let left =0,
right = n -1,
top =0,
bottom = n -1;while(num <= n * n){for(let i = left; i <= right; i++){
maxtrix[top][i]= num;
num++}
top++for(let i = top; i <= bottom; i++){
maxtrix[i][right]= num
num++}
right--for(let i = right; i >= left; i--){
maxtrix[bottom][i]= num
num++}
bottom--;for(let i = bottom; i >= top; i--){
maxtrix[i][left]= num
num++}
left++}return maxtrix
};