public static int[] Rotate(int[] arr , int k)
{
k %= arr.Length;
var ls = new int[arr.Length];
for (int i = 0; i < ls.Length-k; i++)
{
ls[i+k] = arr[i];
}
var j = ls.Length-k;
for (int i = 0; i < k; i++)
{
ls[i] = arr[j++];
}
return ls;
}
function arrayRotate(arr, reverse) {
if (reverse) arr.unshift(arr.pop());
else arr.push(arr.shift());
return arr;
}
function rotate(matrix) {
return matrix[0].map((col, i) => matrix.map((row) => row[i]))
}
function rotateAntiClockwise(matrix) {
return matrix[0].map((col, i) => matrix.map((row) => row[i]).reverse())
}