摘要: 题目链接:https://leetcode.com/problems/swap-nodes-in-pairs//*题意:将链表相邻的两两结点交换*/class Solution {public: ListNode* swapPairs(ListNode* head) { if(h... 阅读全文
posted @ 2015-05-20 17:05 天丶下 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://leetcode.com/problems/sort-list//*题意:对链表进行排序*//** *思路:归并排序 * 分治:将链表分成两段:用slow和fast指针,slow每次只走一步,fast每次 * 走两步。当fast为空时,slow所在位置就... 阅读全文
posted @ 2015-05-20 16:45 天丶下 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://leetcode.com/problems/reorder-list//*题意:给出链表L: L0→L1→…→Ln-1→Ln 转换成 L0→Ln→L1→Ln-1→L2→Ln-2→… *//** *思路:将链表分成两段,分别为A和B,将B反转后插入A中 */cl... 阅读全文
posted @ 2015-05-20 13:19 天丶下 阅读(149) 评论(0) 推荐(0) 编辑