LeetCode-893 Groups of Special-Equivalent Strings Solution (with Java)

1. Description:

Notes:

2. Examples:

3.Solutions: 

 1 /**
 2  * Created by sheepcore on 2019-02-24
 3  */
 4 class Solution {
 5     public int numSpecialEquivGroups(String[] A) {
 6         Set<String> set= new HashSet<>();
 7         for (String s: A){
 8             int[] odd= new int[26];
 9             int[] even= new int[26];
10             for (int i=0; i<s.length(); i++){
11                 if (i%2==1) odd[s.charAt(i)-'a']++;
12                 else even[s.charAt(i)-'a']++;
13             }
14             String sig= Arrays.toString(odd)+Arrays.toString(even);
15             set.add(sig);
16         }
17         return set.size();
18     }
19 }
原文地址:https://www.cnblogs.com/sheepcore/p/12396149.html