LeetCode -- InsertionSor List
来源:互联网 发布:软件企业经营范围 编辑:程序博客网 时间:2024/05/16 01:16
Sort a linked list using insertion sort.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
很简单的插入,当复习一下咯~
public class Solution { public ListNode insertionSortList(ListNode head) { ListNode index = head; ListNode resulthead = new ListNode(-65535); while(index != null){ ListNode temp = resulthead; while(temp.next!=null && temp.next.val < index.val) temp = temp.next; ListNode newNode = new ListNode(index.val); newNode.next = temp.next; temp.next = newNode; index = index.next; } return resulthead.next; }};
0 0
- LeetCode -- InsertionSor List
- leetcode-list
- LeetCode | List
- [leetcode][list] Rotate List
- [leetcode][list] Reorder List
- [leetcode][list] Reorder List
- Leetcode- List - Linked List Cycle
- LeetCode[Linked list]: Rotate List
- LeetCode[Linked List]: Partition List
- [leetcode][list][sort] Sort List
- [leetcode][list] Reverse Linked List
- [leetcode][list] Palindrome Linked List
- 86. Partition List leetcode list
- 61. Rotate List leetcode list
- 143. Reorder List leetcode list
- 148. Sort List leetcode list
- LeetCode: Rotate List
- LeetCode: Partition List
- AS3菜鸟晋级大神必经之路系列(一) 理解flash的显示列表
- 组合
- arc下如何释放内存
- 学习笔记心得
- C/C++内存管理(2)
- LeetCode -- InsertionSor List
- ubuntu pyqt eric
- SIGCHLD信号和waitpid(经典问题)
- 11.2.0.3.0单机PSU到11.2.0.3.11
- Eclipse打包Android项目时用到proguard.cfg后,出现的Warning:can't find referenced class问题的解决方案
- 【翻译自mos文章】对dba_users视图中,account_status列的解释
- 如何用Shell复制一个文件到多个文件夹
- C++学习之多重继承与虚继承
- 我的VIM之路