LeetCode OJ:Insertion Sort List
来源:互联网 发布:淘宝开店得多少钱 编辑:程序博客网 时间:2024/05/08 17:46
Insertion Sort List
Total Accepted: 4162 Total Submissions: 16278My SubmissionsSort 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){ListNode *p=head;ListNode *nh=new ListNode(0);while(p!=NULL){ListNode *q=p->next;insert(nh,p);p=q;}return nh->next;}void insert(ListNode *head,ListNode *cur){ListNode *p=head;ListNode *q=head->next;while(q!=NULL&&q->val<cur->val){p=q;q=q->next;}p->next=cur;cur->next=q;}};
0 0
- LeetCode OJ:Insertion Sort List
- [LeetCode OJ]Insertion Sort List
- LeetCode OJ Insertion Sort List
- Insertion Sort List leetcode oj
- [LeetCode OJ] Insertion Sort List 解题报告
- 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
- 语音识别系统原理介绍---从gmm-hmm到dnn-hmm
- VC++ 6.0的使用——编译,连接,运行
- 机会成本(管理经济学)
- Android 调用WCF
- Erlang基础 - 模块的编译和函数的调用
- LeetCode OJ:Insertion Sort List
- 回调函数
- 软工文档总结
- Unity鼠标中键滚动缩放相机,左键点击场景中模型居中显示
- LeetCode OJ:LRU Cache
- 算法入门之蚂蚁
- Integer to Roman 整数转换成罗马数字
- centos5.5下android开发环境搭建
- 链表:C版单链表代码