Fast and Slow Pointers
文章平均质量分 52
所难
这个作者很懒,什么都没留下…
展开
-
LeetCode-Sort List
Sort a linked list in O(n log n) time using constant space complexity. Solution: Merge Sort原创 2014-07-28 14:56:19 · 438 阅读 · 0 评论 -
LeetCode-Reorder List
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' values. For example, Given {1,2,3,4}, reorder it to原创 2014-07-29 09:33:01 · 368 阅读 · 0 评论 -
LeetCode-Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Solution: Code: /** * Definition for singly-linked list. * struct ListNode原创 2014-07-29 09:55:17 · 426 阅读 · 0 评论 -
LeetCode-Linked List Cycle II
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 extra space? Solution: Code: /** * Definition fo原创 2014-07-29 09:50:03 · 376 阅读 · 0 评论 -
LeetCode-Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Solution: Code:原创 2014-08-03 21:28:37 · 385 阅读 · 0 评论