Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-021

Symmetric Matrix Check

Problem

Return True if matrix A is square and symmetric (A[i][j] == A[j][i] for all i, j).

Return False for any non-square matrix.

Hint

Check the shape first, then compare mirrored entries.

Test cases

case 1
in: [[[1,2],[2,3]]]
expected: true
case 2
in: [[[1,2],[3,4]]]
expected: false
case 3
in: [[[2,0,1],[0,-1,3],[1,3,5]]]
expected: true
case 4
in: [[[1,0],[0,1],[2,2]]]
expected: false
Starter codePython
def is_symmetric(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor