算法好像较多,我总结可能还不是最有效率的算法,但是性能高的算法以牺牲可读可理解性为代价,对于规模有限的问题代码越简单越好,讨论复杂的高性能算法没太大意义。没意义但是面试时很有可能碰到,还是多总结些比较好吧!
int[] x = new int[100];
int[] y = new int[100];
int[] c;
Map aMap = new HashMap();
List aList = new ArrayList();
for(int i = 0 ; i < 100 ; i++){
aMap.put(Integer.valueOf(x[i]),Integer.valueOf(x[i]));
}
for(int i = 0 ; i < 100 ; i++){
Object obj = aMap.get(Integer.valueOf(y[i]));
if (obj != null) {
aList.add(Integer.valueOf(y[i]));
}
}
c = new int[aList.size()];
for (int i = 0; i < aList.size(); i++) {
c[i] = ((Integer)aList.get(i)).intValue();
}