LeetCode OJ
Problems
Pick One!
Submissions
Discuss
Donate
Sign up
Sign in
Sort List
Total Accepted:
615
Total Submissions:
3401
My Submissions
Sort a linked list in
O
(
n
log
n
) time using constant space complexity.
Discuss
C++
Java
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *sortList(ListNode *head) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. } };
/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public class Solution { public ListNode sortList(ListNode head) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. } }
Submit Solution
You have not signed in, cannot submit your code.
Submit failed, try again please.
You have attempted to resubmit too soon. Please resubmit in a moment.
Send Feedback