FastPrepSquare Matrix Rotation and Reflections
Problems/Square Matrix Rotation and Reflections

Square Matrix Rotation and Reflections

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA image describes the square matrix and all three query transformations. We supplied limits and a function signature.

Apply query codes to a square matrix in order: 0 rotates 90 degrees clockwise, 1 reflects across the main diagonal, and 2 reflects across the secondary diagonal. Return the final matrix.

Function

applyMatrixTransforms(matrix: int[][], queries: int[]) → int[][]

Examples

Example 1

matrix = [[1,2],[3,4]]queries = [0]return = [[3,1],[4,2]]
matrix
01012134
→
return
01031142
Moved or new

One clockwise quarter-turn is applied.

Example 2

matrix = [[1,2],[3,4]]queries = [1]return = [[1,3],[2,4]]
matrix
01012134
→
return
01013124
Moved or new

Main-diagonal reflection transposes the matrix.

Constraints

  • 1 <= n <= 200
  • Every query is 0, 1, or 2.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Rotate Matrix Regions Around the DiagonalsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • 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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int[][] applyMatrixTransforms(int[][] matrix, int[] queries) {
        // Write your code here.
    }

}
Checking account…