Merge two sorted linked lists

  • + 0 comments

    My answer with Typescrit,

    Cause no starting code, i was do it for my self

    Questiom sample explain is wrong, it confusing me for a while.

    function main() {
        const ws: WriteStream = createWriteStream(process.env['OUTPUT_PATH']);
        const t: number = parseInt(readLine().trim(), 10);
    
        for (let i = 0; i < t; i++) {
            const n: number = parseInt(readLine().trim(), 10);
            const ns: number[] = []
            for (let j = 0; j < n; j++) ns.push(parseInt(readLine().trim(), 10))
    
            const m: number = parseInt(readLine().trim(), 10);
            const ms: number[] = []
            for (let j = 0; j < m; j++) ms.push(parseInt(readLine().trim(), 10))
    
            ws.write([...ns, ...ms].sort((a, b) => a - b).join(' ') + '\n');
        }
    
        ws.end();
    }