LeetCode OJ Insertion Sort List
2015-03-23 00:39
375 查看
Sort a linked list using insertion sort.
class Solution { public: ListNode *insertionSortList(ListNode *head) { for (ListNode *temp_1 = head; temp_1 != NULL; temp_1 = temp_1->next) { int min = temp_1->val; ListNode *remem = temp_1; for (ListNode *temp_2 = temp_1->next; temp_2 != NULL; temp_2 = temp_2->next) { if (temp_2->val < min) { min = temp_2->val; remem = temp_2; } } remem->val = temp_1->val; temp_1->val = min; } return head; } };
相关文章推荐
- Leetcode[147]-Insertion Sort List
- LeetCode--insertion-sort-list
- LeetCode—Insertion Sort List
- 【leetcode】Insertion Sort List
- leetcode之insertion Sort list
- [LeetCode]题解(python):147-Insertion Sort List
- Insertion Sort List -- leetcode
- leetcode. Insertion Sort List
- LeetCode:Insertion Sort List
- Leetcode155: Insertion Sort List
- Insertion Sort List Leetcode
- LeetCode problem 5: Insertion Sort List
- [LeetCode]Insertion Sort List
- LeetCode---Insertion Sort List
- 【LeetCode with Python】 Insertion Sort List
- Insertion Sort List -- leetcode
- leetcode Insertion Sort List(*)
- [leetcode] Insertion Sort List
- LeetCode 147 Insertion Sort List
- leetcode Insertion Sort List