给定两个二叉树T1,T2判断T1是否是T2的子树
首先在T2中查找T1的根节点,如果找不到,
则T1不是T2的子树,如果能找到,我们可以
遍历T1,检查T1的每个结点是否对应的存在T2
中。
代码:
struct TreeNode
{
int data;
TreeNode* leftChild;
TreeNode* rightChild;
};
bool isExited(co...
分类:
其他好文 时间:
2014-09-09 12:52:58
阅读次数:
171
最近做了个数据管理工具,发生了比较“奇怪”的问题,在eclipse里面直接运行时,功能都可以正常使用,但是导出成为jar包放在桌面就不行了,有的按钮就失效了,或者界面不能正常显示。记录解决思路与过程如下:
1.难道是导出的jar包不是最新的代码,于是我试了试validate和clean up。
结果:没用!
2.用反编译工具将导出的jar包反编译
结果:发现导出的jar包代码是最...
分类:
其他好文 时间:
2014-09-09 12:33:38
阅读次数:
229
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
分类:
其他好文 时间:
2014-09-09 12:23:58
阅读次数:
176
拖拽,主要用到onmousedown、onmouseover、onmouseup 拖拽的流程:(1)先点击 (2)在点下的物体被选中,进行move移动 (3)抬起鼠标,停止移动 【注】点击某个物体时,用oDiv即可,move和up是全局区域,也就是整个文档通用,应...
分类:
其他好文 时间:
2014-09-09 11:40:08
阅读次数:
200
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-09-09 11:30:08
阅读次数:
188
原文地址:http://godick.maxcell.org/opencart-uploaded-file-with-chinese-file-name-doesnt-show-up.html 更改basename函数 admin\controller\common\filemanager.php ...
分类:
其他好文 时间:
2014-09-09 10:32:08
阅读次数:
295
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-09-07 23:40:25
阅读次数:
202
sign up google developer console, create project, generate API keyhttp://stackoverflow.com/questions/4082966/google-web-search-api-deprecated-what-now...
写程序在一棵二叉树中找到两个结点的最近共同祖先。
分两种情况来讨论这个题:
第一种情况结点中没有指向父结点的指针
第二种情况接种有指向父节点的指针
我们先看第一种情况,结点中没有指向父结点的指针。
我们可以采用暴力搜索每一个结点,如果这个结点的子树中
有已知的两个结点,那我们就继续沿着左右子树找,如果左子树
能找到,我们就继续沿着左子树找,如果有子树能找到,我们就
沿着右子...
分类:
其他好文 时间:
2014-09-07 02:13:34
阅读次数:
165
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i...
分类:
其他好文 时间:
2014-09-06 05:27:32
阅读次数:
203