Back to problems

Friend Circle Detection

Algorithm · Amazon · Medium

You receive an N × N adjacency matrix describing friendships among N individuals. A value of 1 at matrix[A][B] means person A knows person B; a 0 means they do not. Because friendship connections carry through intermediaries, count how many separate friendship circles exist. Implement the function: The matrix is symmetric: matrix[A][B] equals matrix[B][A]. Input: An N × N two-dimensional array named matrix, with 1 >>

Checking your access…