147. Insertion Sort List
来源:互联网 发布:eagle软件下载 编辑:程序博客网 时间:2024/06/06 00:49
public ListNode insertionSortList(ListNode head) {
if(head==null){
return null;
}
if(head.next==null){
return head;
}
ListNode rehead=new ListNode(-1);
rehead.next=head;
ListNode pre=head;
ListNode next=head.next;
while(next!=null){
if(pre.val<=next.val){
pre=pre.next;
next=pre.next;
}
else{
ListNode tmp=rehead;
while(tmp.next.val<=next.val){
tmp=tmp.next;
}
pre.next=next.next;
next.next=tmp.next;
tmp.next=next;
next=pre.next;
}
}
return rehead.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
- 【分布式1】 分布式架构
- linux内存管理之内存管理区
- 读书笔记
- LeetCode 59. Spiral Matrix II
- Mongo 聚合框架-Aggregate(三)
- 147. Insertion Sort List
- 《微服务架构与实践》读书笔记
- 练习四(第三周)
- FreeRTOS config开始的宏
- 基于java web开发的在线考试系统
- Git 快速上手精华教程
- spark 共享变量
- PHP-json使用注意点
- LeetCode 62. Unique Paths