Back to problems

Execute matrix transformation commands

Algorithm · Meta · Medium

You are given a two-dimensional integer array matrix and an array of strings commands. Each string describes an operation to perform on the matrix. You must carry out the commands in the exact order they are given and return the matrix after all operations have been applied. The commands can be any of the following five types. All indices are zero-based and refer to the current state of the matrix when the command is executed. "swapRows r1 r2": exchange the rows at positions…

Checking your access…