leetcode---Insertion Sort List
来源:互联网 发布:手机开淘宝店怎么注册 编辑:程序博客网 时间:2024/06/09 13:23
Sort a linked list using insertion sort.
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* insertionSortList(ListNode* head) { if(head == NULL) return NULL; ListNode *start = new ListNode(0); ListNode *cur = head; while(cur) { ListNode *pre = start; while(pre->next && cur->val > pre->next->val) { pre = pre->next; } ListNode *next = cur->next; cur->next = pre->next; pre->next = cur; cur = next; } return start->next; }};
0 0
- Insertion Sort List | leetcode
- Leetcode: Insertion Sort List
- [LeetCode] Insertion Sort List
- Leetcode: Insertion Sort List
- leetcode-Insertion Sort List
- [LeetCode]Insertion Sort List
- 【LeetCode】Insertion Sort List
- LeetCode | Insertion Sort List
- LeetCode - Insertion Sort List
- [LeetCode] Insertion Sort List
- Insertion Sort List (LeetCode)
- [LeetCode] Insertion Sort List
- [LeetCode]Insertion Sort List
- leetcode Insertion Sort List
- Insertion Sort List -- LeetCode
- Insertion Sort List (LeetCode)
- LeetCode Insertion Sort List
- leetcode Insertion Sort List
- 用户登陆的用户名的值传到下一个页面的代码
- NYOJ 655 光棍的yy(大数+斐波那契)
- 对模块化编程的理解
- linux下socket编程的一些学习经历(一)
- 解释什么是字对齐什么是半字对齐(转载)
- leetcode---Insertion Sort List
- HDU 1914 The Stable Marriage Problem 稳定婚姻
- 选择排序算法
- 使用mvc模型实现简易新闻客户端功能(本地)
- MUI框架 栅格化系统
- noip2013 火柴排队 线段树
- VIM插件: DELIMITMATE[符号自动补全]
- Linux C 的进程调度
- 预定义超全局数组$_POST