Pergunta de entrevista da empresa Cruise

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