← Back
00:00

[CodeSignal] Matrix Command Engine

Capital One interview questions · Medium · OA round · 6 tests

You are given an integer matrix grid and an ordered list of command strings. Apply every command in order and return the final matrix.

Interface

runMatrixCommandEngine(
  grid: number[][],
  commands: string[],
): number[][]

Valid commands

  • reverseRow r - reverse the elements of row r.
  • swap r1 r2 - swap rows r1 and r2.
  • rotate - rotate the entire matrix 90 degrees clockwise.
Idle