package leetcode;

/**
 * https://leetcode.com/problems/letter-tile-possibilities/
 */
public class Problem1079 {
    public int numTilePossibilities(String tiles) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1079 prob = new Problem1079();
        System.out.println(prob.numTilePossibilities("AAB")); // 8
        System.out.println(prob.numTilePossibilities("AAABBC")); // 188
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -220,15 +220,117 @@
     
-// TODO
+Set%3CString%3E set = new HashSet%3C%3E();%0A        numTilePossibilities(tiles, %22%22, new boolean%5Btiles.length()%5D, set);
 %0A   
@@ -341,17 +341,26 @@
  return 
-0
+set.size()
 ;%0A    %7D%0A
@@ -365,21 +365,22 @@
 %7D%0A%0A    p
-ublic
+rivate
  static 
@@ -388,214 +388,552 @@
 oid 
-main(String%5B%5D args) %7B%0A        Problem1079 prob = new Problem1079();%0A        System.out.println(prob.numTilePossibili
+numTilePossibilities(String tiles, String accu, boolean%5B%5D visited,%0A                                            Set%3CString%3E set) %7B%0A        if (accu.length() == tiles.length()) %7B%0A            return;%0A        %7D%0A        for (int i = 0; i %3C tiles.length(); i++) %7B%0A            if (visited%5Bi%5D) %7B%0A                continue;%0A            %7D%0A            visited%5Bi%5D = true;%0A            String newStr = accu + 
 ti
+l
 es
-(%22AAB%22)); // 8%0A        System.out.println(prob.numTilePossibilities(%22AAABBC%22)); // 188
+.charAt(i);%0A            set.add(newStr);%0A            numTilePossibilities(tiles, newStr, visited, set);%0A            visited%5Bi%5D = false;%0A        %7D
 %0A   

Solve problem 1079