题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import java.awt.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.DateFormat; import java.text.DecimalFormat; 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; LinkedHashMap<String, Integer> lhm = new LinkedHashMap<>(); while ((str = bf.readLine()) != null) { String[] split = str.split("\\\\"); String s = split[split.length - 1]; String[] s1 = s.split(" "); String s2 = ""; if (s1[0].length() >= 17) { s2 = s1[0].substring(s1[0].length() - 16) + " " + s1[1]; } else { s2 = s1[0] + " " + s1[1]; } if (lhm.containsKey(s2)) { Integer integer = lhm.get(s2); integer++; lhm.put(s2, integer); } else { lhm.put(s2, 1); } } int count = 0; for (Map.Entry<String, Integer> entry : lhm.entrySet()) { count++; if (count > lhm.size() - 8) { System.out.println(entry.getKey() + " " + entry.getValue()); } } } }