package leetcode;

/**
 * https://leetcode.com/problems/custom-sort-string/
 */
public class Problem791 {
    public String customSortString(String S, String T) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem791 prob = new Problem791();
        System.out.println(prob.customSortString("cba", "abcd")); // cbad
    }
}

@@ -168,206 +168,612 @@
     
-// TODO%0A        return null;%0A
+int%5B%5D counts = new int%5B26%5D;%0A        for (char c : T.toCharArray()) %7B%0A            counts%5Bc - 'a'%5D++;%0A   
     
+ 
 %7D
-%0A
 %0A    
-public static void main(String%5B%5D args) %7B%0A        Problem791 prob = new Problem791();%0A        System.out.println(prob.customSortString(%22cba%22, %22abcd%22)); // cbad
+    StringBuilder sb = new StringBuilder();%0A        for (Character c : S.toCharArray()) %7B%0A            for (int i = 0; i %3C counts%5Bc - 'a'%5D; i++) %7B%0A                sb.append(c);%0A            %7D%0A            counts%5Bc - 'a'%5D = 0;%0A        %7D%0A        for (int i = 0; i %3C counts.length; i++) %7B%0A            if (counts%5Bi%5D %3E 0) %7B%0A                for (int j = 0; j %3C counts%5Bi%5D; j++) %7B%0A                    sb.append((char) (i + 'a'));%0A                %7D%0A            %7D%0A        %7D%0A        return sb.toString();
 %0A   

Solve problem 791