Algorithm · ByteDance · Medium
Examples Example 1 Example 2 Requirements Given an n x n square matrix named isSimilar, interpret its entries as follows: A value of 1 at isSimilar[i][j] indicates that photo i is immediately similar to photo j. A value of 0 at isSimilar[i][j] indicates that those two photos have no direct similarity link. Similarity works in both directions, so the matrix represents a symmetric relation. Similarity also carries through chains: when A ~ B and B ~ C, then A ~ C as well.…
Checking your access…