# 893.Groups of Special Equivalent Strings

**893.Groups of Special Equivalent Strings**

难度:Easy

> 你将得到一个字符串数组 A。 如果经过任意次数的移动，S == T，那么两个字符串 S 和 T 是特殊等价的。 一次移动包括选择两个索引 i 和 j，且 i％2 == j％2，并且交换 S\[j] 和 S \[i]。 现在规定，A 中的特殊等价字符串组是 A 的非空子集 S，这样不在 S 中的任何字符串与 S 中的任何字符串都不是特殊等价的。 返回 A 中特殊等价字符串组的数量。

```
示例 1：

输入：["a","b","c","a","c","c"]
输出：3
解释：3 组 ["a","a"]，["b"]，["c","c","c"]
示例 2：

输入：["aa","bb","ab","ba"]
输出：4
解释：4 组 ["aa"]，["bb"]，["ab"]，["ba"]
示例 3：

输入：["abc","acb","bac","bca","cab","cba"]
输出：3
解释：3 组 ["abc","cba"]，["acb","bca"]，["bac","cab"]
示例 4：

输入：["abcd","cdab","adcb","cbad"]
输出：1
解释：1 组 ["abcd","cdab","adcb","cbad"]
 

提示：

1 <= A.length <= 1000
1 <= A[i].length <= 20
所有 A[i] 都具有相同的长度。
所有 A[i] 都只由小写字母组成。
```

> 题目比较晦涩，

```
class Solution {
public:
    int numSpecialEquivGroups(vector<string>& A) {
        if(A.size()==0) return 0;
        int n=A.size(),len=A[0].size();
        //字符串拆分
        string count[n][2];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<len;j+=2) count[i][0].push_back(A[i][j]);
            for(int j=1;j<len;j+=2) count[i][1].push_back(A[i][j]);
            sort(count[i][0].begin(),count[i][0].end());
            sort(count[i][1].begin(),count[i][1].end());
        }
        
        //对统计数据判断
        bool remove[n]={0};
        for(int i=0;i<n-1;i++)
        {
            if(remove[i]==1) continue;
            for(int j=i+1;j<n;j++)
            {
                if(remove[j]==1) continue;
                if(count[i][0]==count[j][0] && count[i][1]==count[j][1])
                    remove[j]=1;
            }
        }
        //统计结果
        int ans=0;
        for(int i=0;i<n;i++) ans+=remove[i];
        return n-ans;
    }
};
```
