I'm not sure whether this Quick Sort Solution is right and bug free, but why Limited Time Exceeded?

```
class Solution {
private:
ListNode* getMiddle(ListNode* head) {
ListNode* slow = head;
ListNode* fast = head -> next;
while (fast && fast -> next) {
slow = slow -> next;
fast = fast -> next -> next;
}
return slow;
}
ListNode* partition(ListNode* head) {
int x = head ? head -> val : 0;
ListNode* leftDummy = new ListNode(0);
ListNode* rightDummy = new ListNode(0);
ListNode* left = leftDummy;
ListNode* right = rightDummy;
while (head) {
if (head -> val < x) {
left -> next = head;
left = left -> next;
}
else {
right -> next = head;
right = right -> next;
}
head = head -> next;
}
right -> next = NULL;
left -> next = rightDummy -> next;
return leftDummy -> next;
}
public:
ListNode* sortList(ListNode* head) {
if (!head || !head -> next) {
return head;
}
ListNode* tail = head;
head = partition(head);
// cout << head -> val << endl;
ListNode* right = sortList(tail -> next);
tail -> next = NULL;
ListNode* left = sortList(head);
tail -> next = right;
return left;
}
};
```