function mergeLists(headone, headtwo) { if (headone === null || headtwo === null) { return headone === null ? headtwo : headone } let p1 = headone.val <= headtwo.val ? headone : headtwo let p2 = p1 === headone ? headtwo : headone const head = p1 head.next = mergeLists(p1.next, p2) return head }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter