при проверке все вроде выводит норм
package com.javarush.task.task18.task1804;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
/*
Самые редкие байты
*/
public class Solution {
public static void main(String[] args) throws Exception {
Map<Integer,Integer> map = new HashMap<>();
List<Integer> list = new ArrayList<>();
int count = Integer.MAX_VALUE;
int shot = 0;
try (FileInputStream fis = new FileInputStream(new Scanner(System.in).nextLine())){
while (fis.available()>0){
int buff = fis.read();
if (!map.containsKey(buff)){
map.put(buff, 1);
}else map.put(buff, map.get(buff)+1);
}
}
for (Map.Entry<Integer,Integer> entry:map.entrySet()){
// System.out.println(entry.getKey() + " = "+ entry.getValue());
if (entry.getValue()<count){
count = entry.getValue();
list.add(shot, entry.getKey());
if (list.size()>1) list.remove(list.size()-1);
}else if (entry.getValue()==count) {
shot++;
list.add(shot, entry.getKey());
}
}
String rezault = "";
for (Integer x:list) rezault+=(x+" ");
System.out.println(rezault.trim());
}
}