摘要: Question Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Solution 判断一个链表是否有环,可以采用slow f 阅读全文
posted @ 2017-06-25 16:10 清水汪汪 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Question Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using ext 阅读全文
posted @ 2017-06-25 15:59 清水汪汪 阅读(156) 评论(0) 推荐(0) 编辑
摘要: LeetCode——Insertion Sort List Question Sort a linked list using insertion sort. Solution 我的解法,假设第一个节点都比其他节点小,这样感觉好移动指针一些,所以添加了一个额外的最小的节点。 Code 阅读全文
posted @ 2017-06-25 14:32 清水汪汪 阅读(108) 评论(0) 推荐(0) 编辑
摘要: LeetCode— Sort List Question Sort a linked list in O(n log n) time using constant space complexity. Solution 看到对链表的排序,时间复杂度O(n log n),首先想到的就是归并排序。 但是这 阅读全文
posted @ 2017-06-25 12:29 清水汪汪 阅读(151) 评论(0) 推荐(0) 编辑