LeetCode Insertion Sort List
来源:互联网 发布:mac怎么玩最终幻想 编辑:程序博客网 时间:2024/06/05 15:34
/** * 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) { ListNode* dummy = new ListNode(-1);//dummy node; ListNode* cur = head;//node to be inserted ListNode* pre=dummy;//node will be inserted between pre and pre->next; ListNode* next ;//cur->next while(cur!=NULL){ next=cur->next; while(pre->next!=NULL&&(pre->next->val<=cur->val)) pre=pre->next; cur->next = pre->next; pre->next = cur; cur=next; pre=dummy; } return dummy->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
- pymysql
- 卡马克:用C++进行函数式编程
- 安装Genymotion出现的错误
- 67.Which two statements are true regarding the ORDER BY clause? (Choose two.)
- Xamarin.Android使用教程之在Android和Xamarin Android Visual Designer中布局
- LeetCode Insertion Sort List
- Go语言发展状况和前景
- 浅谈C++数组与指针(一维)
- 算法 - 排序
- 【实例解析】某水泥企业应用商业智能提升管理效率
- Nagios中常见参数的含义
- IOS开发学习之自定义XIB的使用
- 万向锁
- Spring MVC 文件下载