We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Merge two sorted linked lists
- Discussions
Merge two sorted linked lists
Merge two sorted linked lists
Sort by
recency
|
228 Discussions
|
Please Login in order to post a comment
C#, test case two fails. It seems there is 1 test case, for which the first linked list is 8 ints. The next set of ints for list 2 are unordered it seems. All of my other test cases pass.
the explanation part with sample had mistake ,
Explanation
The first linked list is: 1 -> 3 -> 7 ->NULL The second linked list is: 3->4->NULL Hence, the merged linked list is: 1->2->3->3->4->NULL where is the 7 gone from list 1 ?
Bit hacky but...
Not very clean, but non-recursive solution that uses given class in js:
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]);
}