147. Insertion Sort List
来源:互联网 发布:宜人贷网络贷款 编辑:程序博客网 时间:2024/04/26 01:14
Sort a linked list using insertion sort.
链表的插入排序:
class Solution {public: ListNode* insertionSortList(ListNode* head) { if(head==NULL)return NULL; ListNode *sort_list=new ListNode(0); while(head!=NULL){ ListNode *tmp=head->next; ListNode *cur=sort_list; while(cur->next!=NULL&&cur->next->val<head->val){ cur=cur->next; } head->next=cur->next; cur->next=head; head=tmp; } return sort_list->next; }};
0 0
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- qt下操作串口
- 第十三周项目 1分数类中的运算符重载
- mysql Notifer 图标报红及myeclipse连不上系列问题解决集合
- GNU编译优化级别-O -O1 -O2 -O3
- 《Linux命令行与shell脚本》笔记--第2章:走进shell
- 147. Insertion Sort List
- 第十三周项目-项目1-(3)分数类中的运算符重载
- ShareSDK-Android的使用总结
- Broadcast学习--模仿qq强制下线功能
- poj-1061-青蛙的约会
- 使用handler使用图片轮播及触摸停止
- [Ruby On Rails] Rails 路由学习笔记
- delphi中UTF8Deocde的问题
- 正则表达式整理