LeetCode 147. Insertion Sort List插入排序链表的高效简单解法
来源:互联网 发布:地图矢量化软件 编辑:程序博客网 时间:2024/05/22 02:27
Sort a linked list using insertion sort.
ListNode* insertionSortList(ListNode* head) { if (!head||!head->next) return head; ListNode preHead(0),*pre=&preHead; preHead.next=head; ListNode* cur = head; while (cur) { if (cur -> next && cur -> next -> val < cur -> val) { while (pre -> next && pre -> next -> val < cur -> next -> val) pre = pre -> next; /* Insert cur -> next after pre.*/ ListNode* temp = pre -> next; pre -> next = cur -> next; cur -> next = cur -> next -> next; pre -> next -> next = temp; // Move pre back pre = &preHead; } else cur = cur -> next; } return preHead.next; }
0 0
- LeetCode 147. Insertion Sort List插入排序链表的高效简单解法
- LeetCode Insertion Sort List 链表的插入排序
- leetcode 147. Insertion Sort List-链表插入排序
- LeetCode-147. Insertion Sort List (JAVA)链表插入排序
- leetcode 147. Insertion Sort List 链表插入排序
- 147. Insertion Sort List(链表的插入排序)
- Insertion Sort List 链表插入排序@LeetCode
- LeetCode:Insertion Sort List//链表插入排序
- leetcode Insertion Sort List(链表插入排序)
- LeetCode | Insertion Sort List(插入法排序链表)
- [C++]LeetCode: 126 Insertion Sort List (插入排序链表)
- Leetcode Insertion Sort List 插入排序链表
- LeetCode 147 Insertion Sort List(链表插入排序)
- [LeetCode] Insertion Sort List 单向链表插入排序
- Insertion Sort List 链表插入排序
- Insertion Sort List 链表插入排序
- 链表的插入排序 Insertion Sort List
- Insertion Sort List 链表的插入排序
- Git 常用命令大全
- Windows Server 2003远程桌面多用户连接问题
- 添物不花钱学javaEE--CSS
- IOS Dev Intro - Memory Management
- Butter Knife 使用方法
- LeetCode 147. Insertion Sort List插入排序链表的高效简单解法
- 应用多机房部署
- CentOS7安装Memcached 三步曲
- SCSS Invalid US-ASCII character 处理
- 剑指offer----调整数组顺序使奇数位于偶数前面----java实现
- Java面试宝典(一)
- cvCopy与cvCloneImage、cvCopyimage的区别
- UIActivityIndicatorView活动指示器
- phpstorm下不能得到post数据解决方法