Back to problems

Transpose an Image Matrix

Algorithm · Luma AI · Easy

Write a function named transpose that receives H, W, and matrix, in that order. matrix represents a grayscale image with H rows and W columns. Produce the transposed image: the value originally at row i and column j must be placed at row j and column i. Therefore, the returned matrix has W rows and H columns. Only standard language facilities may be used; third-party libraries are not permitted. Example: Constraints: $$1 \le H, W \le 500$$ $$0 \le \text{matrix}[i][j] \le…

Loading the rest of the question…