[leetcode] Insert sort list
来源:互联网 发布:2017年进出口贸易数据 编辑:程序博客网 时间:2024/05/01 21:25
https://leetcode.com/problems/insertion-sort-list/
/** * 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 || head.next == null) {return head;}ListNode h = new ListNode(0), p = head, pre = h, q = head.next;h.next = head;p.next = null;while (q != null) {while (p != null && q.val >= p.val) {pre = p;p = p.next;}ListNode t = q.next;pre.next = q;q.next = p;q = t;pre = h;p = h.next;}return h.next; }}
0 0
- leetcode:Insert Sort List
- [leetcode] Insert sort list
- [leetcode][list][sort] Sort List
- Insertion Sort List | leetcode
- Leetcode: Insertion Sort List
- [LeetCode] Insertion Sort List
- Leetcode: Insertion Sort List
- Leetcode: Sort List
- Sort List | leetcode
- leetcode-Sort List
- leetcode-Insertion Sort List
- LeetCode题解:Sort List
- leetcode 134: Sort List
- [LeetCode]Sort List
- [LeetCode]Insertion Sort List
- [LeetCode] Sort List
- 【LeetCode】Insertion Sort List
- leetCode - Sort List
- 随波逐流之IOS UIslider详解
- 20个JAVA人员非常有用的功能代码
- Linux bash脚本的调用/注释和运行方式
- APP上线流程总结
- iOS编程-------UITableView表视图 / UITableViewCell的重用机制
- [leetcode] Insert sort list
- 一个并发程序开多少线程合适?
- [Python进阶-4]类的继承/多态/多重继承/任意多参数
- 浅谈android的selector,背景选择器
- jdbc数据库连接
- OpenCV 学习(图像的基本运算)
- POJ3573(模拟)
- java学习笔记]java语言基础概述之内存的划分&堆和栈
- POJ3259 Wormholes SPFA 或者 bellman_ford