package leetcode;

/**
 * https://leetcode.com/problems/groups-of-special-equivalent-strings/
 */
public class Problem893 {
    public int numSpecialEquivGroups(String[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem893 prob = new Problem893();
        System.out.println(prob.numSpecialEquivGroups(new String[]{"a","b","c","a","c","c"})); // 3
        System.out.println(prob.numSpecialEquivGroups(new String[]{"aa","bb","ab","ba"})); // 4
        System.out.println(prob.numSpecialEquivGroups(new String[]{"abc","acb","bac","bca","cab","cba"})); // 3
        System.out.println(prob.numSpecialEquivGroups(new String[]{"abcd","cdab","adcb","cbad"})); // 1
    }
}

@@ -12,16 +12,90 @@
 tcode;%0A%0A
+import java.util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -254,15 +254,207 @@
     
-// TODO
+Set%3CString%3E set = new HashSet%3C%3E();%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            char%5B%5D chars = A%5Bi%5D.toCharArray();%0A            String key = key(chars);%0A            set.add(key);%0A        %7D
 %0A   
@@ -465,17 +465,26 @@
  return 
-0
+set.size()
 ;%0A    %7D%0A
@@ -493,21 +493,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -507,30 +507,30 @@
 tic 
-void main(String
+String key(char
 %5B%5D 
+ch
 ar
-g
 s) %7B
@@ -542,455 +542,621 @@
     
-Problem893 prob = new Problem893();%0A        System.out.println(prob.numSpecialEquivGroups(new String%5B%5D%7B%22a%22,%22b%22,%22c%22,%22a%22,%22c%22,%22c%22%7D)); // 3%0A        System.out.println(prob.numSpecialEquivGroups(new String%5B%5D%7B%22aa%22,%22bb%22,%22ab%22,%22ba%22%7D)); // 4%0A        System.out.println(prob.numSpecialEquivGroups(new String%5B%5D%7B%22abc%22,%22acb%22,%22bac%22,%22bca%22,%22cab%22,%22cba%22%7D)); // 3%0A        System.out.println(prob.numSpecialEquivGroups(new String%5B%5D%7B%22abcd%22,%22cdab%22,%22adcb%22,%22cbad%22%7D)); // 1
+StringBuilder even = new StringBuilder();%0A        StringBuilder odd = new StringBuilder();%0A        for (int j = 0; j %3C chars.length; j++) %7B%0A            if (j %25 2 == 0) %7B%0A                even.append(chars%5Bj%5D);%0A            %7D else %7B%0A                odd.append(chars%5Bj%5D);%0A            %7D%0A        %7D%0A        char%5B%5D evenChars = even.toString().toCharArray();%0A        Arrays.sort(evenChars);%0A        String evenString = new String(evenChars);%0A        char%5B%5D oddChars = odd.toString().toCharArray();%0A        Arrays.sort(oddChars);%0A        String oddString = new String(oddChars);%0A        return evenString + %22%7C%22 + oddString;
 %0A   

Solve problem 893