Given a list of strings, return the number of groups where two strings belong to the same group if they are identical or can become identical after swapping exactly two characters. DSU path compression keeps group merging efficient.
strs = array of equal-length strings
number of similar string groups
Example 1:
Input:
strs = ["tars","rats","arts","star"]
Output:
2
Explanation:
The strings split into two similarity groups.
Example 2:
Input:
strs = ["omv","ovm"]
Output:
1
Explanation:
The two strings differ by one swap.
Example 3:
Input:
strs = ["abc","abc","abc"]
Output:
1
Explanation:
Identical strings are all in the same group.