题解 | #整型数组合并#
整型数组合并
https://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void (async function () { // Write your code here let index = 0; let str = ""; // 合并后的字符串 while ((line = await readline())) { switch (index) { case 0: case 2: index++; break; case 1: case 3: str = str.concat(line," "); index++; break; default: break; } } const tokens = str.split(" "); // 合并后的字符串拆成数组 tokens.sort((a,b)=>(a-b)); const final = Array.from(new Set(tokens)); // 去重 console.log(final.join("")); })();