Leetcode Problem 148. Sort List

148. Sort List

Leetcode Solutions

Top Down Merge Sort for Linked List

  1. If the head is null or there is only one element in the linked list, return the head as it is already sorted.
  2. Use the fast and slow pointer technique to find the middle of the linked list.
  3. Recursively sort the two halves of the linked list.
  4. Merge the two sorted halves into a single sorted list.
  5. Return the head of the merged sorted list.
UML Thumbnail

Bottom Up Merge Sort for Linked List

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...