Flatten Binary Tree to Linked List
Total Accepted: 25034 Total
Submissions: 88947My Submissions
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1...
分类:
其他好文 时间:
2014-10-11 20:54:36
阅读次数:
214
Remove Duplicates from Sorted List I
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3...
分类:
其他好文 时间:
2014-10-11 16:50:15
阅读次数:
206
# Definition for singly-linked list.class ListNode: def __init__(self, x): self.val = x self.next = Noneclass Solution: # @para...
分类:
其他好文 时间:
2014-10-10 19:36:04
阅读次数:
167
Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a...
分类:
其他好文 时间:
2014-10-10 00:17:43
阅读次数:
355
题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al...
分类:
其他好文 时间:
2014-10-09 00:31:07
阅读次数:
234
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n =
4,
return 1->4->3->2->5->NULL.
Note:
Given m, n satisfy t...
分类:
其他好文 时间:
2014-10-08 15:33:25
阅读次数:
154
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 t...
分类:
其他好文 时间:
2014-10-08 15:01:15
阅读次数:
159
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?使用快慢指针,如果有循环两指针必定能相遇: 1 p...
分类:
编程语言 时间:
2014-10-08 04:32:34
阅读次数:
298
Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, r...
分类:
其他好文 时间:
2014-10-08 01:26:44
阅读次数:
239
题目:Sort ListSort a linked list in O(n log n) time using constant space complexity看题目有两个要求:1)时间复杂度为O(nlogn);2)空间复杂度为常数,即不能增设额外的空间。满足这样要求的排序算法,我们首先想到快排,...
分类:
其他好文 时间:
2014-10-07 19:28:53
阅读次数:
245