leetcode之Insertion Sort List
来源:互联网 发布:网页展示 excel数据 编辑:程序博客网 时间:2024/05/20 22:35
问题描述如下:
Sort a linked list using insertion sort.
问题链接
cpp代码如下:
class Solution {public: ListNode *insertionSortList(ListNode *head) { if(head==NULL||head->next==NULL)return head; ListNode node(0); node.next=head; ListNode* p=head->next,*r=head; while(p){ ListNode* q=&node; for(;q->next!=p&&q->next->val<p->val;q=q->next); if(q->next==p){ r=p; p=p->next; } else{ r->next=p->next;; p->next=q->next; q->next=p; p=r->next; } } return node.next; }};
0 0
- 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
- leetcode-Insertion Sort List
- [LeetCode]Insertion Sort List
- 【LeetCode】Insertion Sort List
- LeetCode | Insertion Sort List
- LeetCode - Insertion Sort List
- linux 下打包与解包
- java中JSON解析(字典里套用字典)
- 各种数据库的连接方式汇总
- Android 如何使用internal 和 hidden API
- Swift 1.1语言快速入门7.2使用无参函数
- leetcode之Insertion Sort List
- Android优秀开源项目
- 0098 Java设计模式01--策略模式【进阶】
- ORACLE计算一年的12个月份及一些日期函数
- Android通过Servlet连接阿里云服务器的mysql <一>(servlet编程)
- 按钮左边是圆角,右边是方角
- 技术团队的情绪与效率
- 优秀Java程序员的编程风格
- win7下启动nexus报错:The nexus-webapp service was launched, but failed to start解决