题解 | #整型数组合并#

整型数组合并

https://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b

import java.util.*;
import java.lang.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> set = new TreeSet<>();
        int m = sc.nextInt();
        // int[] arr1 = new int[m];
        for(int i=0; i<m; i++){
            // arr1[i] = sc.nextInt();
            set.add(sc.nextInt());
        }
        int n = sc.nextInt();
        // int[] arr2 = new int[n];
        for(int i=0; i<n; i++){
            // arr2[i] = sc.nextInt();
            set.add(sc.nextInt());
        }
        StringBuffer sb = new StringBuffer();
        for(Integer i: set){
            sb.append(i);
        }
        System.out.println(sb.toString());
    }
}

全部评论

相关推荐

05-23 19:33
重庆大学 Java
只学了传统后端,马上去后端实习了,在想要不要学习agent开发相关的。27秋招和26相比难度如何?
我连备胎都不是却还在...:就暑期实习而言,大厂官宣hc 比 26 多,但是我观察看应该低于 26 的,估计秋招也不简单
点赞 评论 收藏
分享
飞屋一号:实话实说就行,先争取一下能不能线上,不行就直接放弃,付出与回报不成正比
我的求职进度条
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务