LintCode-链表插入排序
来源:互联网 发布:电子设备审计软件功能 编辑:程序博客网 时间:2024/05/21 12:45
容易 链表插入排序
用插入排序对链表排序
您在真实的面试中是否遇到过这个题?Yes
样例
Given 1->3->2->0->null
, return 0->1->2->3->null
冒泡法遍历
/** * Definition for ListNode. * public class ListNode { * int val; * ListNode next; * ListNode(int val) { * this.val = val; * this.next = null; * } * } */ public class Solution { /** * @param head: The first node of linked list. * @return: The head of linked list. */ public ListNode insertionSortList(ListNode head) {boolean flag = true;ListNode frist = head;ListNode second = head;if(head.next == null || head == null){return head;}else{frist = head.next;}while(flag){flag = false;do{if(frist.val<second.val){int x =frist.val;frist.val = second.val;second.val = x;flag = true;}frist = frist.next;second = second.next;}while(frist != null);frist = head.next;second = head;}return head;}}
0 0
- LintCode 链表插入排序
- lintcode-链表插入排序
- LintCode-链表插入排序
- 链表插入排序 lintcode
- LintCode 链表插入排序
- 链表插入排序-LintCode
- LintCode 链表插入排序
- 链表插入排序-LintCode
- LintCode(E) 链表插入排序
- lintcode 173 链表插入排序
- Lintcode——链表插入排序
- 【lintcode】——链表插入排序-Insertion Sort List
- LintCode : 链表排序
- lintcode,链表排序
- LintCode 链表排序
- 链表排序-LintCode
- lintcode--链表排序
- 链表排序 -lintcode
- 设计模式
- svn 提交.a静态库文件方法
- scp命令
- 《学习日记》prototype,_proto_以及call\apply方法理解
- HDU 2577 How to Type(DP)
- LintCode-链表插入排序
- C++ Primer 学习笔记_19_语句 --if/switch/while/for语句
- POSTGRESQL 存储过程 select into 和 insert into select 两种表复制语句之间的差别
- mysql的查询、子查询及连接查询
- Openbr: nmake编译过程中出现 file DOWNLOAD HASH mismatch问题
- PBR:应用于虚幻引擎4贴图和材质创建的启示
- Web Service的三大技术
- android:layout_weight="1"
- 一个为OpenFlow规则分配与端点规则实施而设计的通用最优化框架(五)