#32 - Identity Matrix

An identity matrix is a square matrix in which all the elements of the principal diagonal are ones and all other elements are zeros.

Your task is to implement a function to check if a given square matrix is an identity matrix.

Example 1

Input

mat = [
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1]
]

Output

True

Example 2

Input

mat = [
    [1, 0, 0, 0],
    [0, 1, 0, 0],
    [0, 0, 1, 0],
    [0, 0, 0, 1]
]     

Output

True

Last updated