3999. Minimum Number of String Groups Through Transformations
You are given an array of strings
words.Define a transformation on a string
sas follows:
- Let
Ebe the subsequence of characters at even indices ofs.- Let
Obe the subsequence of characters at odd indices ofs.- Independently cyclically shift
EandOby any number of positions to the right, possibly zero.- Reconstruct the string by placing the shifted
Echaracters back into even indices and the shiftedOcharacters back into odd indices.Two strings are equivalent if one can be transformed into the other by a single transformation.
Partition
wordsinto the minimum number of groups such that:
- Every string belongs to exactly one group.
- Every pair of strings in the same group are equivalent.
Return an integer denoting the minimum number of groups.