题解 | #整型数组合并#

整型数组合并

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

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

/**
 * @author hll[yellowdradra@foxmail.com]
 * @since 2023-03-24 15:40
 **/
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextLine();
        String s1 = in.nextLine();
        in.nextLine();
        String s3 = in.nextLine();
        String s = Stream.of(s1, s3)
                .flatMap(x -> Stream.of(x.split(" ")))
                .mapToInt(Integer::parseInt)
                .distinct()
                .sorted()
                .mapToObj(String::valueOf)
                .reduce((x, y) -> x + y)
                .orElse("");
        System.out.println(s);
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务