leetcode[147]:Insertion Sort List
来源:互联网 发布:php nginx 虚拟机配置 编辑:程序博客网 时间:2024/04/28 18:03
Insertion Sort List
Sort a linked list using insertion sort.
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct ListNode* insertionSortList(struct ListNode* head) { struct ListNode *L,*p,*tmp; if(!head || !head->next) return head; p = head->next; L=head; L->next = NULL; while(p) { tmp=p; p=p->next; if(tmp->val < head->val) { tmp->next=head; head=tmp; } else{ while(tmp->val > L->val) { if(!L->next) break; if(L->next->val < tmp->val) L=L->next; else break; } tmp->next=L->next; L->next=tmp; } L=head; } return head;}
直接插入排序。双指针?
0 0
- LeetCode(147) Insertion Sort List
- LeetCode: Insertion Sort List [147]
- LeetCode 147 Insertion Sort List
- [leetcode 147] Insertion Sort List
- LeetCode 147 Insertion Sort List
- LeetCode 147 Insertion Sort List
- [leetcode 147]Insertion Sort List
- leetcode-147 Insertion Sort List
- [LeetCode 147]Insertion Sort List
- Leetcode[147]-Insertion Sort List
- Insertion Sort List - LeetCode 147
- leetcode[147]:Insertion Sort List
- LeetCode(147) Insertion Sort List
- leetcode 147: Insertion Sort List
- [Leetcode]#147 Insertion Sort List
- leetCode #147 Insertion Sort List
- LeetCode 147 Insertion Sort List
- LeetCode 147:Insertion Sort List
- DOM解析器 (三)
- JAVA实现远程录屏或广播屏幕
- jq写点击指定div以外的其他地方隐藏此div
- nginx 内存池
- DOM解析器(四)
- leetcode[147]:Insertion Sort List
- activity切换时的overridePendingTransition动画效果
- 多线程
- 字符串-07. 说反话-加强版 (20)【测试点3、4段错误】
- LintCode-寻找峰值
- java byte 与 int float转换
- poj 1469 COURSES(二分匹配 vector 邻接表 实现)
- DOM解析器(五)
- oracle substr,substrb ,instr,instrb函数的用法以及like的优化