Google | Telephonic | Backend developer | Bengaluru | Feb 2022 [Reject]
Anonymous User
382

Given a 2D binary array (0 and 1), count the number of all possible triangles formed by digit '1'.
Conditions:

  1. Every digit 1 represents an individual triangle too.

  2. Triangles that formed with more than one row of the matrix, must satisfy the below condition.
    Let's first row one '1' (row number = 0)
    Second row should have 2 * row number + 1 = 2 * 1 + 1 = 3 (row number = 1)
    Third row should have 2 * row number + 1 = 2 * 2 + 1 = 5 (row number = 2)

Examplee:
(1) Total trianlges = 5
00100
01110

Comments (3)