package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character/
 */
public class Problem1170 {
    public int[] numSmallerByFrequency(String[] queries, String[] words) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1170 prob = new Problem1170();
        System.out.println(Arrays.toString(prob.numSmallerByFrequency(new String[]{"cbd"}, new String[]{"zaaaz"}))); // [1]
        System.out.println(Arrays.toString(prob.numSmallerByFrequency(new String[]{"bbb","cc"}, new String[]{"a","aa","aaa","aaaa"}))); // [1,2]
    }
}

@@ -249,403 +249,1131 @@
     
-// TODO%0A        return null
+int%5B%5D answer = new int%5Bqueries.length%5D;%0A        int i = 0;%0A        int%5B%5D queryMinFreqs = getMinFreqs(queries)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1170 prob = new Problem1170();%0A        System.out.println(Arrays.toString(prob.numSmallerByFrequency(new String%5B%5D%7B%22cbd%22%7D, new String%5B%5D%7B%22zaaaz%22%7D))); // %5B1%5D%0A        System.out.println(Arrays.toString(prob.numSmallerByFrequency(new String%5B%5D%7B%22bbb%22,%22cc%22%7D, new String%5B%5D%7B%22a%22,%22aa%22,%22aaa%22,%22aaaa%22%7D))); // %5B1,2%5D
+int%5B%5D wordMinFreqs = getMinFreqs(words);%0A        for (int query : queryMinFreqs) %7B%0A            int count = 0;%0A            for (int word : wordMinFreqs) %7B%0A                if (query %3C word) %7B%0A                    count++;%0A                %7D%0A            %7D%0A            answer%5Bi++%5D = count;%0A        %7D%0A        return answer;%0A    %7D%0A%0A    private static int%5B%5D getMinFreqs(String%5B%5D strings) %7B%0A        int%5B%5D%5B%5D counts = new int%5Bstrings.length%5D%5B%5D;%0A        int i = 0;%0A        for (String str : strings) %7B%0A            int%5B%5D count = new int%5B26%5D;%0A            for (char c : str.toCharArray()) %7B%0A                count%5Bc - 'a'%5D++;%0A            %7D%0A            counts%5Bi++%5D = count;%0A        %7D%0A        int%5B%5D minFreqs = new int%5Bstrings.length%5D;%0A        for (int j = 0; j %3C counts.length; j++) %7B%0A            for (int k = 0; k %3C counts%5Bj%5D.length; k++) %7B%0A                if (counts%5Bj%5D%5Bk%5D %3E 0) %7B%0A                    minFreqs%5Bj%5D = counts%5Bj%5D%5Bk%5D;%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A        return minFreqs;
 %0A   

Solve problem 1170