Square Matrix Rotation and Reflections
Updated
Problem statement
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]]Moved or new
One clockwise quarter-turn is applied.
Example 2
matrix = [[1,2],[3,4]]queries = [1]return = [[1,3],[2,4]]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