Merge two sorted linked lists

  • + 0 comments

    I solved it in ts using arrays istead of linked lists, bc I didn´t wanted to declare classes.

    And also I think the challenge is poorly explained.

    function main(il: string[]) { const arr: number[] = il.map(Number); const len = Number(arr.splice(0, 1)[0]);

    for (let i = 0; i < len; i++) {
        const res: number[] = [];
    
        for (let j = 0; j <= 1; j++) {
            const newLen = arr[0];
            arr.splice(0, 1);
    
            res.push(...arr.splice(0, newLen));
        }
    
        console.log(res.sort((a, b) => a - b).join(" "));
    }
    

    }