147. Insertion Sort List

Medium

Problem:

Sort the linked list using insertion sort.

https://leetcode.com/problems/insertion-sort-list/arrow-up-right

Solution:

Insertion sort divides the task into two groups: the ones that need to be sorted and the ones that have been sorted.

  • We can sort by comparing the items that need sorting, head and cur.next.

  • parent always points to that position.

Last updated