https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/



Runtime: 157 ms, faster than 5.00% of TypeScript online submissions for Determine Whether Matrix Can Be Obtained By Rotation.

Memory Usage: 48 MB, less than 5.00% of TypeScript online submissions for Determine Whether Matrix Can Be Obtained By Rotation.



```typescript
function rotate(source: number[][]): number[][] {
    const tempMatrix = [];
    
    for (const [column_index, _] of source[0].entries()) {
        const tempRow = [];
        for (const [_, row] of source.entries()) {
            tempRow.push(row[column_index]);
        }
        tempMatrix.push([...tempRow.reverse()]);
    }
    
    return [...tempMatrix];
}

function isMatrixEqual(a: number[][], b: number[][]): boolean {
    for (const [row_index, row] of a.entries()) {
        for (const [column_index, value] of row.entries()) {
            if (value != b[row_index][column_index]) {
                //console.log(a, b, "\n")
                return false;
            }
        }
    }
    return true;
}

function findRotation(mat: number[][], target: number[][]): boolean {
    //9:48
    const a = rotate(mat);
    const b = rotate(a);
    const c = rotate(b);
    const d = rotate(c);
    
    return isMatrixEqual(a, target) || isMatrixEqual(b, target) || isMatrixEqual(c, target) || isMatrixEqual(d, target);
    //9:58
    //debug until 10:14; `array.reverse().entries()` won't work
};
```
