Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-06-12 18:32:00
阅读次数:
222
Reverse Linked List IIReverse a linked list from
positionmton. Do it in-place and in one-pass.For example:Given
1->2->3->4->5->NULL, m= 2 andn= 4,retu...
分类:
其他好文 时间:
2014-06-12 07:03:54
阅读次数:
308
Partition ListGiven a linked list and a valuex,
partition it such that all nodes less thanxcome before nodes greater than or
equal tox.You should pres...
分类:
其他好文 时间:
2014-06-12 06:18:55
阅读次数:
562
题目
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
方法
有序链表,合并成一个有序链表。
public ListNod...
分类:
其他好文 时间:
2014-06-10 18:13:11
阅读次数:
241
问题:
给定一个链表的头指针,以及一个整数k,要求将链表按每k个为一组,组内进行链表逆置。少于k个的部分不做处理。
分析:
个人觉得问题的重点是熟悉链表的就地逆置操作,就是头插法。其他的考察点如果还有的话,就的细心程度。
实现:
void reverseList(ListNode *&pre, ListNode *head)
{
ListNode *tail = NULL;
w...
分类:
其他好文 时间:
2014-06-10 17:25:45
阅读次数:
305
Given a linked list and a valuex, partition it
such that all nodes less thanxcome before nodes greater than or equal tox.You
should preserve the origi...
分类:
其他好文 时间:
2014-06-10 12:06:09
阅读次数:
205
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
Clarification:
What constitutes a word?
A sequence of non-space ch...
分类:
其他好文 时间:
2014-06-10 11:12:06
阅读次数:
185