大约的意思就是:1 - 100之间的数字 存到数组里 有95个 
你怎样判断缺少的那5个数字大家应该能明白我说的吧 哈哈

解决方案 »

  1.   

    Add all the elements in the array to a HashMap, and make sure the key equals the value. So the keys without values are the missing elements.
      

  2.   

    Is it better to use an int array of length 100?
      

  3.   

    Nice!!! int[] array = new int[100];
    int[] source = new int[95];for (int i=0; i<100; i++)
       array[source[i]] = source[i];
    ...
      

  4.   

    最直接的方法,用辅助数组。如果是找出一个这样的数,有取巧的办法。这里用hashmap不觉得效率会提高多少。
      

  5.   


    public class Test {  
    public List left(Integer[] a,Integer[] b){//c1是相对大的集合,C2是小集合
    List<Integer> c1 = new ArrayList<Integer>(),
           c2= new ArrayList<Integer>(),
           list = new ArrayList<Integer>();
    c1.addAll(Arrays.asList(a));
    c2.addAll(Arrays.asList(b));
    for(int i=0;i<c1.size();i++){
    if(!c2.contains(c1.get(i))){
    list.add(c1.get(i));
    }
    }
    return list;
    }

        public static void main(String[] args) {
         Integer[] c ={1,2,3,4,56,6};
         Integer[] d = {2,3,4};
        
        
         List list = new Test().left(c, d);
         for(Object o:list){
         System.out.println((Integer)o);
         }
        }  
    } 比较包不包含,不包含就加入集合
    算法挺简单的,但定义东西多