[Leetcode] #147 Insertion Sort List
2017-02-11 15:32
477 查看
Discription:
Sort a linked list using insertion sort.Solution:
ListNode* insertionSortList(ListNode* head) { if (!head) return head; ListNode *head1 = new ListNode(-1), *head2 = head->next; head1->next = head; while (head2){ head = head1; while (head->next && head->next->val <= head2->val) { head = head->next; } ListNode *temp = head2->next; head2->next = head->next; head->next = head2; head2 = temp; } return head1->next; }
GitHub-LeetCode: https://github.com/wenwu313/LeetCode
相关文章推荐
- leetcode[147]Insertion Sort List
- [leetcode147]insertion sort list
- LeetCode(147) Insertion Sort List
- LeetCode 147 Insertion Sort List
- leetcode-147 Insertion Sort List
- (Leetcode 147)Insertion Sort List
- [Leetcode]#147 Insertion Sort List
- LeetCode(147) Insertion Sort List
- LeetCode147: Insertion Sort List
- leetcode-Insertion Sort List-147
- Leetcode 147 Insertion Sort List
- Java for LeetCode 147 Insertion Sort List
- LeetCode 147:Insertion Sort List
- leetcode 147 Insertion Sort List java 算法
- 【LEETCODE】147- Insertion Sort List [Python]
- LeetCode 147 Insertion Sort List(链表)
- leetcode[147]:Insertion Sort List
- [LeetCode]147 Insertion Sort List
- LeetCode147_Insertion Sort List(用插入排序算法对链表进行排序) Java题解
- [leetcode 147]Insertion Sort List