Question d’entretien chez Cruise

Coding interview on codapad. Find all connected same values node in a matrix.