Given a binary tree, determine if it is a valid
binary search tree (BST).Assume a BST is defined as follows:The left subtree of
a node contains only n...
分类:
其他好文 时间:
2014-06-03 14:00:56
阅读次数:
281
bfs+优先队列。wa了N次,才发现可以停留等待楼梯变换方向。 1 #include 2
#include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXNUM 55 8 9
typedef struct node...
分类:
其他好文 时间:
2014-06-03 13:26:06
阅读次数:
274
图的数组表示法借助一个二维数组表示图,该二维数组的第i行,第j列的值表示从Node[i]到Node[j]:无向图(网):是否有边 / 权值,arr[i][j]
== arr[j][i],无向图(网)的特性,矩阵关于对角线对称。有向图(网):是否有弧 / 权值。//图的数组表示法//最大顶点个数con...
分类:
其他好文 时间:
2014-05-30 21:56:24
阅读次数:
394
题目描述:输入一个链表,反转链表后,输出链表的所有元素。(hint :
请务必使用链表)输入:输入可能包含多个测试样例,输入以EOF结束。对于每个测试案例,输入的第一行为一个整数n(0next也就是p1来改变p1元素的位置,代码如下:Node
*p = head->next; Node *p1...
分类:
其他好文 时间:
2014-05-30 21:55:06
阅读次数:
349
Follow up for problem "Populating Next Right
Pointers in Each Node".What if the given tree could be any binary tree? Would
your previous solution stil...
分类:
其他好文 时间:
2014-05-30 16:17:49
阅读次数:
210
Given a binary tree, find the maximum path
sum.The path may start and end at any node in the tree.For example:Given the
below binary tree, 1 ...
分类:
其他好文 时间:
2014-05-30 16:10:54
阅读次数:
185
Given a linked list, return the node where the
cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it
without using extra space?/**...
分类:
其他好文 时间:
2014-05-30 15:59:56
阅读次数:
249
A linked list is given such that each node
contains an additional random pointer which could point to any node in the list
or null.Return a deep copy ...
分类:
其他好文 时间:
2014-05-30 15:07:49
阅读次数:
260
题目描述:输入一个链表,输出该链表中倒数第k个结点。(hint:
请务必使用链表。)输入:输入可能包含多个测试样例,输入以EOF结束。对于每个测试案例,输入的第一行为两个整数n和k(0#include typedef
struct node{ int number; struct nod...
分类:
其他好文 时间:
2014-05-30 00:29:13
阅读次数:
325
题意:computing a max-spacingk-clustering.spacing 是指两个
cluster 之间的最小距离输入:[number_of_nodes][edge 1 node 1] [edge 1 node 2] [edge 1
cost][edge 2 node 1] [e...
分类:
其他好文 时间:
2014-05-29 20:40:30
阅读次数:
323