Insertion Sort List (LeetCode)
来源:互联网 发布:手机天文软件 编辑:程序博客网 时间:2024/05/19 22:04
Sort a linked list using insertion sort.
public ListNode insertionSortList(ListNode head) { if(head==null) return null; ListNode small = head, large = head, run = head.next; while(run!=null){ if(run.val <= small.val){ large.next = run.next; run.next = small; small = run; run = large.next; } else if(run.val >=large.val){ large = run; run = run.next; } else{ ListNode tmp = small; while(tmp.next.val < run.val) tmp = tmp.next; large.next=run.next; run.next = tmp.next; tmp.next = run; run = large.next; } } return small; }
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
- 一位软件工程师的6年总结
- 使用socket实现简单的统计站点人数
- Distinct Subsequences 哥们总算自己写个自底向上的dp解
- HDU 4529 郑厂长系列故事——N骑士问题(dp,状态压缩)
- ood
- Insertion Sort List (LeetCode)
- 2014年1月14日(DEMO7-2,加载PLG)
- Evaluate Reverse Polish Notation (LeetCode)
- Sort List (LeetCode)
- [CrackCode] 1.4 Write a method to decide if two strings are anagrams or not
- 鼠标右键
- HDU 4549 M斐波那契数列 (费马小定理降幂&矩阵快速幂)
- Reorder List (LeetCode)
- 已知递推式求第N项的O(logN)算法 (递推式转化为矩阵)