Matrix Symmetry Check
You are provided with a square matrix. Your task is to return true
if the matrix is symmetric; otherwise, return false
.
A symmetric matrix is characterized by its transpose being equal to the matrix itself.
Example of Symmetric Matrix:
Please refer to the example image below.
Input:
The first line contains an integer 'T', the number of test cases or queries to be executed.
Each test case starts with an integer 'N', representing the size of the square matrix.
The following line contains 'N' * 'N' integers, representing the matrix in a row-wise manner.
Output:
For each test case/query, output true
if the matrix is symmetric; otherwise, output false
.
Each result should be printed on a new line.
Constraints:
1 <= T <= 10
1 <= N <= 10^2
-10^9 <= data <= 10^9
Note:
The 'data' refers to individual elements within the matrix.
The function implementation should avoid print statements; output handling is pre-configured.
Time Limit: 1 second

AnswerBot
4mo
Check if a square matrix is symmetric by comparing it with its transpose.
Iterate through the matrix and compare each element with its corresponding element in the transpose
If any pair of elements do n...read more
Help your peers!
Add answer anonymously...
Popular interview questions of Software Engineer
A Software Engineer was asked Q1. Given a binary tree, determine if it is height-balanced.
A Software Engineer was asked Q2. Given the head of a singly linked list, determine if the linked list has a cycle...read more
A Software Engineer was asked Q3. Railway Seat Berth Determination Given a railway seat number represented as an i...read more
>
Josh Technology Group Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

