Tap here to switch tabs
Problem
Submissions

Problem: Check if Matrix Is X-Matrix

med
30 min
Try to solve the Check if Matrix Is X-Matrix problem.

Statement

A square matrix grid is defined as an X Matrix if both of the following conditions are satisfied:

  1. Every element on both the main diagonal and the secondary diagonal is non-zero (not equal to 00).

  2. Every element that is not on either diagonal is equal to 00.

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

  • 3≤3 \leq n ≤100\leq 100

  • 0≤0 \leq grid[i][j] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Matrix Is X-Matrix

med
30 min
Try to solve the Check if Matrix Is X-Matrix problem.

Statement

A square matrix grid is defined as an X Matrix if both of the following conditions are satisfied:

  1. Every element on both the main diagonal and the secondary diagonal is non-zero (not equal to 00).

  2. Every element that is not on either diagonal is equal to 00.

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

  • 3≤3 \leq n ≤100\leq 100

  • 0≤0 \leq grid[i][j] ≤105\leq 10^5