Sort-----147. Insertion Sort List
来源:互联网 发布:java工程师如何考试 编辑:程序博客网 时间:2024/06/05 17:03
原题目
链表的插入排序,就是维护一个新链表,然后从原来链表中提数字插入就是了。思想有点像反转链表。
public ListNode insertionSortList(ListNode head) { ListNode dummy = new ListNode(0); ListNode p = head; while (p != null) { ListNode q = dummy; while (q.next != null && q.next.val < p.val) { q = q.next; } ListNode temp = p.next; p.next = q.next; q.next = p; p = temp; } return dummy.next; }
阅读全文
0 0
- Sort-----147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- 147. Insertion Sort List
- FreeRTOS中断分析
- Linux BIOS启动代码DS与ES寄存器初始化分析
- WEBLOGIC连接RAC
- 常用 Git 命令清单
- 管理UNDO
- Sort-----147. Insertion Sort List
- 解决Weblogic域创建、启动、进入控制台慢问题
- WIN下使用PYTHON和JAVA作OPENCV开发
- 机器学习-特征衍生
- 类和对象
- RegularExpression
- EventBus3.0中粘性事件postSticky使用
- 优化问题及其Lagrange对偶问题
- SQL空值在连接中的处理