题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Map<String, Integer> map = new TreeMap();
while (sc.hasNext()) {
String b = sc.nextLine();
if (b.equals("")) continue;
map.put(b, map.getOrDefault(b, 0) + 1);
}
map.forEach((k, v) -> {
for (Integer i = 0; i < v; i++) {
System.out.println(k);
}
});
}
}
仅需要处理一下相同字符串的存储的问题

