题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static java.util.Arrays.*;
import static java.util.stream.Stream.*;
public class Main {
public static void main(String[] args) throws IOException {
testTh();
}
private static void testTh() throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String str;
while ((str=bf.readLine())!=null){
str= bf.readLine();
String[] s = str.split(" ");
LinkedHashMap<String,Integer> hashMap=new LinkedHashMap<>();
for (String s1 : s) {
hashMap.put(s1,0);
}
str= bf.readLine();
str= bf.readLine();
int Invalid=0;
String[] split = str.split(" ");
for (String s1 : split) {
if (hashMap.containsKey(s1)){
Integer integer = hashMap.get(s1);
integer++;
hashMap.put(s1,integer);
}else {
Invalid++;
}
}
hashMap.forEach((o1,o2)->{
System.out.println(o1+" : "+o2);
});
System.out.println("Invalid"+" : "+Invalid);
}
}
}
查看19道真题和解析
上海得物信息集团有限公司公司福利 1164人发布