Tap here to switch tabs
Problem
Submissions

Problem: Cyclically Rotating a Grid

med
30 min
Try to solve the Cyclically Rotating a Grid problem.

Statement

You are given an m × \times n integer matrix grid, where both m and n are even integers, and an integer k.

The matrix is composed of concentric rectangular layers. Rotate each layer of the matrix cyclically in the counterclockwise direction by k positions.

Return the modified grid after performing the rotations.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 2≤2 \leq m, n ≤50\leq 50

  • Both m and n are even integers.

  • 1≤1 \leq grid[i][j] ≤5000\leq 5000

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Cyclically Rotating a Grid

med
30 min
Try to solve the Cyclically Rotating a Grid problem.

Statement

You are given an m × \times n integer matrix grid, where both m and n are even integers, and an integer k.

The matrix is composed of concentric rectangular layers. Rotate each layer of the matrix cyclically in the counterclockwise direction by k positions.

Return the modified grid after performing the rotations.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 2≤2 \leq m, n ≤50\leq 50

  • Both m and n are even integers.

  • 1≤1 \leq grid[i][j] ≤5000\leq 5000

  • 1≤1 \leq k ≤109\leq 10^9