René's URL Explorer Experiment


Title: #148 - Sort List - LeetCode JavaScript Solutions

Open Graph Title: #148 - Sort List - LeetCode JavaScript Solutions

X Title: #148 - Sort List - LeetCode JavaScript Solutions

Description: Given the head of a linked list, return the list after sorting it in ascending order. ...

Open Graph Description: Given the head of a linked list, return the list after sorting it in ascending order. ...

X Description: Given the head of a linked list, return the list after sorting it in ascending order. ...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/sort-list

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/sort-list","name":"#148 - Sort List - LeetCode JavaScript Solutions","description":"Given the head of a linked list, return the list after sorting it in ascending order. ...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n *     this.val = (val===undefined ? 0 : val)\n *     this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param {ListNode} head\n * @return {ListNode}\n */\nvar sortList = function(head) {\n  if (!head || !head.next) return head;\n  let fast = head;\n  let slow = head;\n  while (fast.next && fast.next.next) {\n    fast = fast.next.next;\n    slow = slow.next;\n  }\n  const middle = slow.next;\n  slow.next = null;\n  return mergeList(sortList(head), sortList(middle));\n};\n\nfunction mergeList(a, b) {\n  const ordered = new ListNode(-1);\n  let list = ordered;\n\n  while (a && b) {\n    list.next = a.val < b.val ? a : b;\n    list = list.next;\n    if (a.val < b.val) {\n      a = a.next;\n    } else {\n      b = b.next;\n    }\n  }\n\n  list.next = a ?? b;\n  return ordered.next;\n}","keywords":"LeetCode 148, #148 - Sort List, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}

authorLeetCodeJavascript.com
og:typearticle
og:imagehttps://leetcodejavascript.com/og-image.jpg
og:site_nameLeetCode JavaScript Solutions
twitter:cardsummary_large_image
twitter:urlhttps://leetcodejavascript.com/solutions/sort-list
twitter:imagehttps://leetcodejavascript.com/og-image.jpg
twitter:creator@joshcrozier
theme-color#1f2937

Links:

LeetCodeJavascript.com https://leetcodejavascript.com/
Star on GitHub https://github.com/JoshCrozier/leetcode-javascript
Back to all solutions https://leetcodejavascript.com
View on LeetCode https://leetcode.com/problems/sort-list/
View on GitHub https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0148-sort-list.js
Sorting https://leetcodejavascript.com/tags/sorting
Two Pointers https://leetcodejavascript.com/tags/two-pointers
Linked List https://leetcodejavascript.com/tags/linked-list
Divide and Conquer https://leetcodejavascript.com/tags/divide-and-conquer
Merge Sort https://leetcodejavascript.com/tags/merge-sort
Josh Crozierhttps://joshcrozier.com

Viewport: width=device-width, initial-scale=1.0

Robots: index, follow


URLs of crawlers that visited me.