> For the complete documentation index, see [llms.txt](https://dfine.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dfine.gitbook.io/leetcode/893.groups_of_special_equivalent_strings.md).

# 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;
    }
};
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dfine.gitbook.io/leetcode/893.groups_of_special_equivalent_strings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
