图的深度优先遍历是树的前序遍历的应用,其实就是一个递归的过程,我们人为的规定一种条件,或者说一种继续遍历下去的判断条件,只要满足我们定义的这种条件,我们就遍历下去,当然,走过的节点必须记录下来,当条件不满足后,我们就return,回到上一层,换个方向继续遍历。模板:
1 //邻接矩阵存储方式 2 b...
分类:
其他好文 时间:
2014-06-08 23:50:57
阅读次数:
420
//定义二维平面上的点struct Point{ int x; int y;
Point(int a=0, int b=0):x(a),y(b){}};bool operator==(const Point& left,
const Point& right){ return...
分类:
其他好文 时间:
2014-06-08 22:26:17
阅读次数:
357
原题地址:https://oj.leetcode.com/problems/sqrtx/题意:Implementint
sqrt(int x).Compute and return the square root
ofx.解题思路:实现开平方函数。这里要注意的一点是返回的时一个整数。通过这一点我们可...
分类:
编程语言 时间:
2014-06-08 21:04:38
阅读次数:
329
#include #include #include #include using
namespace std;int cmp(const void *a,const void *b){ return *(int *)a-*(int
*)b;}int main(){ int n; ...
分类:
其他好文 时间:
2014-06-08 20:51:16
阅读次数:
202
原题地址:https://oj.leetcode.com/problems/add-binary/题意:Given
two binary strings, return their sum (also a binary string).For example,a ="11"b
="1"Return"...
分类:
编程语言 时间:
2014-06-08 20:28:04
阅读次数:
300
题目
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not c...
分类:
其他好文 时间:
2014-06-08 05:32:21
阅读次数:
196
题目
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
...
分类:
其他好文 时间:
2014-06-08 04:01:05
阅读次数:
240
public boolean equals(Object otherObject) {
if(this == otherObject) { // 检测this与otherObject是否引用同一个对象
return true;
}
if(null == otherObject ) { // 检测otherObject是否为空
ret...
分类:
编程语言 时间:
2014-06-08 04:00:26
阅读次数:
299
一般 为了阻止默认事件,我们都用return false,但是 如果你用了事件绑定,return false在高版本浏览其中就会失效,但是低版本浏览器中还是可以的,我们可以使用事件对象里面preventDefault()方法来去解决高版本浏览器中事件绑定了无法用return false阻止默认事件的问题。
例如:取消鼠标右击后出现的默认菜单
document.oncontextmenu=fun...
分类:
其他好文 时间:
2014-06-08 03:52:20
阅读次数:
380
Implement wildcard pattern matching with support for '?' and '*'.public class Solution {
public boolean isMatch(String s, String p) {
if (s == null || p == null) return false;
if (...
分类:
编程语言 时间:
2014-06-08 03:10:46
阅读次数:
216