X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Hard Accuracy: 66.85% Submissions: 8986 Points: 8

Sort the given doubly linked list of size N using quicksort. Just complete the partition function using the quicksort technique.

Example 1:

Input:
Output:
2 4 9


Example 2:

Input:
Output:
1 2 4 9


Your task is to complete the given function partition(), which accepts the first and last node of the given linked list as input parameters and returns the pivot's address.

Expected Time Complexity: O(NlogN)
Expected Auxilliary Space: O(1)

Constraints:
1 <= N <= 200