Symmetric matrix

Write a function that, given a square matrix @m@, tells if it is symmetric or not.

Remember that a matrix mm is symmetric if mi,j=mj,im_{i,j}=m_{j,i} for any ii and for any jj.

Precondition

@m@ is a square matrix n×nn\times n with n0n \ge 0.

Interface

C++
typedef vector< vector<int> > Matrix;
bool is_symmetric(const Matrix& m);
Java
public static boolean isSymmetric(int[][] m);
Python
is_symmetric(m)  # returns bool
MyPy
is_symmetric(m: list[list[int]]) -> bool

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:09:34.820Z

© Jutge.org, 2006–2026.
https://jutge.org