摘要: Question: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' 阅读全文
posted @ 2018-02-27 16:48 于淼 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Question: Sort a linked list using insertion sort. Tips: 使用插入排序,对一个链表进行排序。 思路: 新建一个头结点newHead,设置一个pre指针,指向newHead。 cur指针,指向原来的头结点head。 当pre.next的值大于cu 阅读全文
posted @ 2018-02-27 12:04 于淼 阅读(95) 评论(0) 推荐(0) 编辑