Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Transpose a rectangular matrix

Hardware interview practice

Transpose a rectangular matrix

EasyMatricesSystemVerilog

Return the transpose of an R x C integer matrix as a new C x R matrix.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
matrix = [[1, 2, 3], [4, 5, 6]]
Expected output
[[1, 4], [2, 5], [3, 6]]

Rows become columns, so a 2x3 input produces a 3x2 output.

What to cover

Requirements

  1. Return an empty matrix for an empty input.
  2. Assume every input row has the same number of columns.
  3. Allocate every output row to the original row count.
  4. Assign out[c][r] from input[r][c].
asic.fyi · Learn silicon end to end.info@asic.fyi