DescriptionQ225
Q225FWASIC interview problem
Transpose a square matrix in place
TechniquesMatrixIn place
DifficultyEasy
TopicMatrices
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
Transpose an N x N matrix in place.
Example input and output
Use this case to check your interpretationInput
matrix = [[1, 2], [3, 4]]Output
[[1, 3], [2, 4]]Explanation
Swapping the off-diagonal pair performs the square transpose in place.
02
Requirements (4)
- Assume the input has N rows and every row has exactly N elements.
- Swap only one side of the diagonal.
- Leave diagonal elements unchanged.
- Use O(1) extra space.
