Pular para o conteúdo principal

2 documentos selecionados com "union-find"

Ver todas os Marcadores

Friend Circles

This question is asked by Facebook. You are given a two dimensional matrix, friends, that represents relationships between coworkers in an office. If friendsi = 1 then coworker i is friends with coworker j and coworker j is friends with coworker i. Similarly if friendsi = 0 then coworker i is not friends with coworker j and coworker j is not friend with coworker i. Friendships in the office are transitive (i.e., if coworker one is friends with coworker two and coworker two is friends with coworker three, coworker one is also friends with coworker three). Given the friendships in the office defined by friends, return the total number of distinct friends groups in the office.

Is Graph Bipartite

This question is asked by Facebook. Given an undirected graph, determine whether it is bipartite.