LeetCode OJ
Problems
Pick One!
Submissions
Discuss
Donate
Sign up
Sign in
Send Feedback
Sort List
Total Accepted:
5146
Total Submissions:
26238
My Submissions
Sort a linked list in
O
(
n
log
n
) time using constant space complexity.
Discuss
C++
Java
Python
/** * 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) { } };
/** * 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) { } }
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return a ListNode def sortList(self, head):
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