A square matrix grid is defined as an X Matrix if both of the following conditions are satisfied:
Every element on both the main diagonal and the secondary diagonal is non-zero (not equal to
Every element that is not on either diagonal is equal to
Given a two-dimensional integer array grid of size n × n, return true if grid is an X Matrix, or false otherwise.
Constraints:
n grid.length grid[i].length
n
grid[i][j]
A square matrix grid is defined as an X Matrix if both of the following conditions are satisfied:
Every element on both the main diagonal and the secondary diagonal is non-zero (not equal to
Every element that is not on either diagonal is equal to
Given a two-dimensional integer array grid of size n × n, return true if grid is an X Matrix, or false otherwise.
Constraints:
n grid.length grid[i].length
n
grid[i][j]