- Bucket for string $i \rightarrow [s, k, m]$
- Bucket for string $j \rightarrow [i, s, k]$
This effectively implies that $i,j,s,k,m$ belong to the same cluster.
One of the ways I could do this is to build a connectivity graph and cluster all the connected components.
The other way is to iteratively check for the matches.
Could somebody help me do it better.