Sort array of strings after sorting each string after removing characters whose frequencies are not a powers of 2

import java.io.*;import java.lang.*;import java.util.*;class GFG{static boolean isPowerOfTwo(int n){             if (n == 0)        return false;        return (Math.ceil(Math.log(n) / Math.log(2)) ==           Math.floor(Math.log(n) / Math.log(2)));}static void printArray(ArrayList res){             Collections.sort(res);        for(int i = 0; i < res.size(); i++)    {        System.out.print(res.get(i) + " ");    }}static void sortedStrings(String S[], int N){                 HashMap freq = new HashMap();            ArrayList res = new ArrayList();        for(int i = 0; i < N; i++)    {                         String st = "";                        for(int j = 0; j < S[i].length(); j++)        {                                     freq.put(S[i].charAt(j),                freq.getOrDefault(S[i].charAt(j), 0) + 1);        }                for(char ch : freq.keySet())        {                                                 if (isPowerOfTwo(freq.get(ch)))            {                                for(int j = 0; j < freq.get(ch); j++)                {                    st += ch;                }            }        }                freq.clear();                if (st.length() == 0)            continue;                        char myCharArr[] = st.toCharArray();        Arrays.sort(myCharArr);        String ns = "";                 for(int j = myCharArr.length - 1; j >= 0; –j)            ns += myCharArr[j];                res.add(ns);    }             printArray(res);}public static void main(String[] args){    String arr[] = { “aaacbb”, “geeks”, “aaa” };    int N = arr.length;         sortedStrings(arr, N);}}