#3128

Right Triangles

specialist · 910 · lc medium +31 · 48.4% accepted · 133 likes · top 34%

Description

Given a 2D boolean matrix grid, three 1-valued cells form a right triangle when one cell shares its row with a second cell and shares its column with the third cell (the three need not be adjacent). Return the total count of such right triangles.

Code

1
2
3