题解 | #整型数组合并#
整型数组合并
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); } }