Ezvor

737. Sentence Similarity II

MediumArray Preparing judge… LeetCode
ArrayHash TableStringDepth-First SearchBreadth-First SearchUnion-Find

Hints

Hint 1
Consider the graphs where each pair in "pairs" is an edge. Two words are similar if they are the same, or are in the same connected component of this graph.