public class Main {     public HashMap<Integer, Integer> calc(String strings){         HashMap<Integer, Integer> map = new HashMap<>();         int []arr = new int [strings.length()];         for(int i = 0;i<arr.length;i++)         {             arr[i] = strings.charAt(i)-48;             if(map.containsKey(arr[i])){                 map.put(arr[i],map.get(arr[i])+1);             }else{                 map.put(arr[i], 1);             }         }         return map;     }     public static void main(String[] args) {         // TODO Auto-generated method stub         // 统计字符串每个数字的次数         Scanner in = new Scanner(System.in);         String string = in.nextLine();         Main nMain = new Main();         HashMap<Integer, Integer> map = nMain.calc(string);                  ArrayList<Integer> aList = new ArrayList<>();         for(int i =0;i<Integer.MAX_VALUE;i++){             //拿到子 map             HashMap<Integer, Integer> map2 = nMain.calc(i+"");             // 比较 子map  和 主map的关系                 Iterator<Entry<Integer, Integer>> iterator = map2.entrySet().iterator();                 while(iterator.hasNext()){                     Entry<Integer,Integer> entry = iterator.next();                     int key = entry.getKey();                     int value = entry.getValue();                     if(map.containsKey(key)==false||map.get(key)<value){                         System.out.println("min="+i);                         return;                     }                 }         }     } }
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务