题解 | #集合#
集合
https://www.nowcoder.com/practice/635ff765d4af45b5bf8e3756ed415792
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); TreeSet<Integer> set = new TreeSet<>(); while(n-- != 0) { set.add(in.nextInt()); } int x; while(m!= 0) { x = in.nextInt(); set.add(x); m--; } for(int i : set) { System.out.print(i + " "); } } }