2)有两个字符串数组a和b,寻找相同元素(a、b都很大,用伪代码);(这个我真不会)
groovy版
groovy版
class Merger {
def static main(args){
String[] str1 = ["A","B","C","D","E","F","G","A"];
String[] str2 = ["C","D","E","F","G","H","I","H","I"];
Map map = new HashMap();
List list = new ArrayList();
str1.each{ map.put(it,1) }
str2.each{ map.get(it)?list.add(it):null }
println list;
}
}