# Special Positions in a Binary Matrix SOLUTION

Page Contents

### Special Positions in a Binary Matrix SOLUTION

Given a columns x cols grid tangle, where mat[i][j] is either 0 or 1, return the quantity of unique situations in tangle.

A position (i,j) is called unique if mat[i][j] == 1 and all different components in line I and segment j are 0 (lines and sections are 0-filed).

Model 1:

Info: tangle = [[1,0,0],

[0,0,1],

[1,0,0]]

Yield: 1

Clarification: (1,2) is an extraordinary position in light of the fact that mat == 1 and all different components in line 1 and segment 2 are 0.

Model 2:

Information: tangle = [[1,0,0],

[0,1,0],

[0,0,1]]

Yield: 3

Clarification: (0,0), (1,1) and (2,2) are unique positions.

Model 3:

Information: tangle = [[0,0,0,1],

[1,0,0,0],

[0,1,1,0],

[0,0,0,0]]

Yield: 2

Model 4:

Information: tangle = [[0,0,0,0,0],

[1,0,0,0,0],

[0,1,0,0,0],

[0,0,1,0,0],

[0,0,0,1,1]]

Yield: 3

Requirements:

lines == mat.length

cols == mat[i].length

1 <= lines, cols <= 100

mat[i][j] is 0 or 1.