Imagine you have a square matrix of numbers, and you're given a set of instructions, called queries, to transform this matrix in different ways. Depending on the query, you might rotate the matrix 90 degrees clockwise, reflect it along its main diagonal, or reflect it along its secondary diagonal. Your task is to apply all these transformations in the order given and return the matrix after it's been beautifully transformed by each of the queries. Don't worry about finding the most efficient way to do this; just ensure your approach isn't too slow for the given task.
Example 1:
Input: a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], q = [0, 1, 2]
Output: [[3, 6, 9], [2, 5, 8], [1, 4, 7]]
Explanation:An explanation based on educated guess. Might be right might be wrong tho..After processing the queries on matrix
a
:
- First query is
0
, so we rotate the matrix 90 degrees clockwise.- Second query is
1
, so we reflect the rotated matrix in its main diagonal.- Third query is
2
, so we reflect the matrix in its secondary diagonal.The final matrix after all transformations is
[[3, 6, 9], [2, 5, 8], [1, 4, 7]]
.
๐๐


input:
output: