Tap here to switch tabs
Problem
Submissions

Problem: Sort Linked List Already Sorted Using Absolute Values

med
30 min
Try to solve the Sort Linked List Already Sorted Using Absolute Values problem.

Statement

Given the head of a singly linked list that is sorted in nondecreasing order based on the absolute values of its nodes, sort the linked list in nondecreasing order by the actual values of its nodes and return the sorted list.

Constraints:

  • The number of nodes in the list is in the range [1,105][1, 10^5].

  • −5000≤-5000 \leq Node.val ≤5000\leq 5000

  • head is sorted in nondecreasing order using the absolute value of its nodes.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sort Linked List Already Sorted Using Absolute Values

med
30 min
Try to solve the Sort Linked List Already Sorted Using Absolute Values problem.

Statement

Given the head of a singly linked list that is sorted in nondecreasing order based on the absolute values of its nodes, sort the linked list in nondecreasing order by the actual values of its nodes and return the sorted list.

Constraints:

  • The number of nodes in the list is in the range [1,105][1, 10^5].

  • −5000≤-5000 \leq Node.val ≤5000\leq 5000

  • head is sorted in nondecreasing order using the absolute value of its nodes.