题解 | #整型数组合并#
整型数组合并
https://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b
import java.util.Scanner; import java.util.TreeSet; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { TreeSet<Integer> set = new TreeSet<>(); int num1 = in.nextInt(); for (int i = 0; i < num1; i++) { set.add(in.nextInt()); } int num2 = in.nextInt(); for (int i = 0; i < num2; i++) { set.add(in.nextInt()); } int size = set.size(); for (int i = 0; i < size; i++) { System.out.print(set.pollFirst()); } System.out.println(); } } }