LeetCode 147 Insertion Sort List(链表)
来源:互联网 发布:2200万淘宝买家资料 编辑:程序博客网 时间:2024/06/04 00:46
Sort a linked list using insertion sort.
代码如下:
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ void swap(int* a, int* b) { int tmp = *a; *a = *b; *b = tmp; }struct ListNode* insertionSortList(struct ListNode* head) { struct ListNode* ptr; if(!head) return NULL; for(ptr = head->next;ptr;ptr = ptr->next){ for(struct ListNode* tmp = head;tmp != ptr;tmp = tmp->next){ if(tmp->val > ptr->val) swap(&ptr->val, &tmp->val); } } return head;}
0 0
- LeetCode 147 Insertion Sort List(链表)
- LeetCode(147) Insertion Sort List
- 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
- 利用eclipse打开github项目
- IPython 下的信息收集-魔力函数(page pinfo who等)- 千月的python linux 系统管理指南学习笔记(9)
- Hibernate三种实体映射,从建表到操作代码
- 设计模式-组合模式
- KVO实现自定义文件复制进度展示
- LeetCode 147 Insertion Sort List(链表)
- 16国赛1题
- Md5实现算法源码
- 基于DEM提取经纬度
- Leetcode-标签为Tree 111. Minimum Depth of Binary Tree
- Maven tomcat7-maven-plugin 部署Maven Web 项目
- Android自定义控件系列之应用篇——圆形进度条
- JQuery日期插件datepicker的使用
- 机器视觉光源知识总结(二)