Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路:与http://www.cnblogs.com/...
分类:
其他好文 时间:
2015-08-09 10:40:41
阅读次数:
164
二叉树数据结构声明:
struct TreeNode
{
int val;
TreeNode *left;
TreeNode *right;
};
1、递归求二叉树深度
int getDepth(TreeNode *root)
{
if (root == NULL)
{
return 0;
}
re...
分类:
其他好文 时间:
2015-08-09 08:24:11
阅读次数:
204
Selenium 获取 JavaScript 返回值非常简单,只需要在 js 脚本中将需要返回的数据 return 就可以,然后通过方法返回 js 的执行结果,方法源码如下所示: 1 /** 2 * Get Object of return from js 3 * 4 ...
分类:
编程语言 时间:
2015-08-09 07:10:34
阅读次数:
183
题目Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums excep...
分类:
其他好文 时间:
2015-08-09 07:08:48
阅读次数:
110
QuestionlinkGiven a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to botto...
分类:
其他好文 时间:
2015-08-09 01:51:28
阅读次数:
129
Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur...
分类:
其他好文 时间:
2015-08-09 01:42:40
阅读次数:
206
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th...
分类:
其他好文 时间:
2015-08-09 00:21:20
阅读次数:
142
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all d...
分类:
其他好文 时间:
2015-08-09 00:17:58
阅读次数:
154
就是那一个数组保存已经到过的点
每一个数组存储的都是这个点到nm的路线数
#include
using namespace std;
int n,m;
int dp[100][100];
int a[100][100];
int p=0;
int dfs(int x,int y){p++;
if(dp[x][y]>0) return dp[x][y];
dp[x][y]...
分类:
其他好文 时间:
2015-08-08 22:56:36
阅读次数:
121
分治法求最大连续和
注意范围是[x,y)
#include
using namespace std;
int maxsum(int *A,int x,int y){
if(y-x==1) return A[x];
int m=x+(y-x)/2;
int maxs = max(maxsum(A,x,m),maxsum(A,m,y));
int v,L,R;...
分类:
编程语言 时间:
2015-08-08 22:52:35
阅读次数:
136