Given a squared matrix where each row represent an individual and each cell whether that person gave a gift to another one. For Example (0,1) -> 1 means individual 0 gave something to individual 1, thus, (1,0) is also -> 1. The goal is to create a function such that it creates groups base on the gift of each individual following the logic that if ind 1 gave something to ind 2 and ind 2 gave something to ind 3 then ind 1 through 3 are part of that group.
The input is a matrix as follow:
input
[
[1,1,0,0],
[1,1,1,0],
[0,1,1,0],
[0,0,0,1]
]
output -> [[0,1,2], [3]]
I got this question in an interview but I could solve it, I'm not looking for an answer but for pointers on what do i need to know in order to solve it.
Thanks