public static void solve()throws IOException {
int n = ri();
char s[] = rac();
HashMap<Character , Integer>map = new HashMap<>();
for(char ch : s) {
map.put(ch , map.getOrDefault(ch,0) + 1);
}
// _ _ _
List list = new ArrayList<>(map.keySet());
Collections.sort(list,(a,b)-> map.get(b)-map.get(a));
char ans[] = new char[n];
Arrays.fill(ans , ‘-’);
TreeSet set = new TreeSet<>();
for(int i =0;i < n;i++) {
set.add(i);
}
for(char ch : list) {
int cnt = map.get(ch);
if(set.size() == 0) {
System.out.println(“NO”);
return ;
}
int index = set.first();
while(cnt > 0) {
if(index >= n) {
System.out.println(“NO”);
return ;
}
ans[index] = ch;
set.remove(index);
index+=3;
cnt–;
}
}
System.out.println("YES");
System.out.println(new String(ans));
}
Can someone please tell me for which test case my code is not working