leetcode Insertion Sort List
来源:互联网 发布:apache cgi python 编辑:程序博客网 时间:2024/06/05 02:29
题目链接
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode insertionSortList(ListNode head) { if(head==null) { return head; } ListNode result=head; ListNode current=head.next; head.next=null; while(current!=null) { ListNode temp=current.next; if(result.val>current.val) { current.next=result; result=current; current=temp; continue; } ListNode pointer=result; while(pointer.next!=null&¤t.val>pointer.next.val) { pointer=pointer.next; } if(pointer.next==null) { pointer.next=current; current.next=null; } else { current.next=pointer.next; pointer.next=current; } current=temp; } return result; }}
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
- JAVA学习笔记整理七(JDK5新特性)
- Android手绘效果实现
- Hibernate 单向 多 对 1 对象关系映射 下 ,测试 crud
- QT 打开 保存 文件对话框
- spark环境搭建及简单程序使用
- leetcode Insertion Sort List
- Win10应用商店如何改变应用的安装位置
- jdbc模版
- docker 相关
- debian ext4 打包问题
- Java基础回顾 : 打印流和扫描流
- 图论之最小生成树
- linux 64系统 字符串 md5 加密问题
- Mybatis初识