FastPrepRotate Matrix Regions Around the Diagonals
Problems/Rotate Matrix Regions Around the Diagonals

Rotate Matrix Regions Around the Diagonals

Susquehanna International Group (SIG) logoSusquehanna International Group (SIG)● MediumNEW GRADFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a SIG online assessment. The report directly gives a square matrix, one to four clockwise turns of the four regions separated by the two diagonals, diagonal cells that stay fixed, and the full 5 x 5 example kept below. The return form of the function, the number limits, and two smaller examples are ours, added only so you can run the reported task. They do not change the reported transformation.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question appeared again on September 29, 2026 and November 8, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 💚

You are given an n x n integer matrix and an integer turns. The main diagonal and anti-diagonal divide the cells outside the diagonals into top, right, bottom, and left regions.

One turn rotates those four regions clockwise by 90 degrees: every non-diagonal value at (row, column) moves to (column, n - 1 - row). Every cell on either diagonal stays fixed.

Apply exactly turns turns and return the resulting matrix.

Function

rotateMatrixOverDiagonals(matrix: int[][], turns: int) → int[][]

Examples

Example 1

matrix = [[1,2,3,4,5],[2,1,9,6,3],[7,0,4,8,1],[5,2,4,1,9],[6,4,3,2,1]]turns = 1return = [[1,5,7,2,5],[4,1,0,6,2],[3,4,4,9,3],[2,2,8,1,4],[6,9,1,3,1]]
matrix
01234012345121963270481352419464321
→
return
01234015725141062234493322814469131
Moved or new

The diagonal values remain in place. Every other value advances clockwise into the next triangular region.

Example 2

matrix = [[1,2,3],[4,5,6],[7,8,9]]turns = 1return = [[1,4,3],[8,5,2],[7,6,9]]
matrix
012012314562789
→
return
012014318522769
Moved or new

The four off-diagonal values 2, 6, 8, 4 move clockwise, while 1, 3, 5, 7, 9 stay fixed.

Example 3

matrix = [[7]]turns = 3return = [[7]]
matrix
007
→
return
007

The only cell lies on both diagonals, so every turn leaves it unchanged.

Constraints

  • 1 <= n <= 200.
  • matrix.length = matrix[i].length = n.
  • -10^9 <= matrix[i][j] <= 10^9.
  • 1 <= turns <= 4.

More Susquehanna International Group (SIG) Online Assessment questions

  • Catch Fish with Reusable BaitsOA · Seen Nov 2026
  • Bold Play to Reach a GoalOA · Seen Nov 2026
  • Cats, Truth and Who Has MoreOA · Seen Nov 2026
  • Counting Cows by Their LegsOA · Seen Nov 2026
  • Enough Muffins for the LineOA · Seen Nov 2026
  • Expected Consecutive Pairs Among Chosen NumbersOA · Seen Nov 2026
  • Four-by-Four Boundary GridOA · Seen Nov 2026
  • Frog Paths Without Long RunsOA · Seen Nov 2026
  • Higher Roll, or Lose the SumOA · Seen Nov 2026
  • Is a Popular Story Fake?OA · Seen Nov 2026

Similar questions at other companies

  • Rotate Matrix Regions Around the DiagonalsHudson River Trading · OAHudson River Trading interview questions
  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Sort Every Matrix Border LayerCapital One · OACapital One interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions
  • Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions

Susquehanna International Group (SIG) interview experiences

  • SIG Quant Researcher Experienced Hire Interviews: 11 Experiences
  • SIG Quant Research Intern Interviews: 60 Experiences
  • SIG Quant Researcher New Grad Interviews: 49 Experiences
  • SIG Quant Researcher Intern Interviews: 1 Experience
  • SIG Quant Second-Round Tech Screen: 1 Experience
All Susquehanna International Group (SIG) interview questionsSee Susquehanna International Group (SIG) hiring insights
Saved
class Solution {
    public int[][] rotateMatrixOverDiagonals(int[][] matrix, int turns) {
        // write your code here
    }
}
Checking account…