Rotate Four Matrix Regions While Keeping Diagonals Fixed

Given an n × n integer matrix matrix and an integer turns (1 <= turns <= 4), perform the following operation exactly turns times:

  • Elements on the main diagonal (r == c) and anti-diagona...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: