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 nodes with keys less than the node's key.Th...
分类:
其他好文 时间:
2014-08-05 09:43:39
阅读次数:
191
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 still work?
Note:
You may only use constant ...
分类:
其他好文 时间:
2014-08-05 00:51:38
阅读次数:
249
##Director游戏主循环显示Node ###DisplayLinkDirector继承Director override了以下方法 ``` virtual void mainLoop() override; virtual void setAnimationInterval(double value) override; virtual void start...
分类:
其他好文 时间:
2014-08-04 21:51:08
阅读次数:
396
//next_permutation全排列
# include
# include
# include
using namespace std;
struct node
{
int w;
int v;
};
struct node a[10010];
int max1(int x,int y)
{
return x>y?x:y;
}
int main()
{
int i,n,d,fl...
分类:
其他好文 时间:
2014-08-04 21:33:18
阅读次数:
279
Cocos2d-x3.1中回调函数的定义在CCRef.h中声明,源码如下:
typedef void (Ref::*SEL_CallFunc)();
typedef void (Ref::*SEL_CallFuncN)(Node*);
typedef void (Ref::*SEL_CallFuncND)(Node*, void*);
typedef void (Ref::*SEL_Call...
分类:
其他好文 时间:
2014-08-04 18:04:17
阅读次数:
222
题目意思和POJ2342一样,只是多加了一个条件,如果最大方案数唯一,输出Yes,不唯一输出No
dp的是时候多加一个变量记录答案是否唯一即可
#include "stdio.h"
#include "string.h"
#include "vector"
using namespace std;
struct node
{
int fa;
vectorchi...
分类:
其他好文 时间:
2014-08-04 18:02:17
阅读次数:
250
题目:存在一个单链表,头指针为head,实现单链表的反转Node *Reverse(Node *head)。
该算法的求解办法有很多,如:
方法1:先顺序变量单链表,将结点保存到栈中,在从栈中弹出结点,重新建立一个新的单链表;
方法2:用《剑指offer》里面给出的算法,用三个指针来实现;
方法3:采用递归实现,是方法2的递归实现形式。
本文主要给出方法2和方法3,在给出具体的代码之前,先要注意几个问题:
...
分类:
其他好文 时间:
2014-08-04 18:01:57
阅读次数:
200
Trie的应用题目。
本题有两个难点了:
1 动态建立Trie会超时,需要静态建立数组,然后构造树
2 判断的时候注意两种情况: 1) Tire树有133,然后插入13333556的时候,2)插入顺序倒转过来的时候
修改一下标准Trie数的插入函数就可以了:
#include
#include
const int MAX_NODE = 100001;
const int M...
分类:
其他好文 时间:
2014-08-04 17:44:47
阅读次数:
213
题目:已知有两个有序的单链表,其头指针分别为head1和head2,实现将这两个链表合并的函数:
Node* ListMerge(Node *head1,Node *head2)
这个算法很像我们排序算法中的归并排序,只能说“很像”,因为思想是一样的,但是这个与归并排序还是有区别的,区别如下:
1.归并排序是针对有序数组,而这里是有序链表;
2.归并排序排序的时间复杂度为o(nlogn),而这里的时间复杂度最坏情况下为O(m+n),最好的情况下为...
分类:
其他好文 时间:
2014-08-04 17:43:47
阅读次数:
296
1,概述CommonJS是服务器端模块的规范,Node.js采用了这个规范。根据CommonJS规范,一个单独的文件就是一个模块。加载模块使用require方法,该方法读取一个文件并执行,最后返回文件内部的exports对象。下面就是一个简单的模块文件example.js。console.log("...
分类:
Web程序 时间:
2014-08-04 17:33:37
阅读次数:
300