这道题好像不是回溯就是简单的递归,全排列一下就ok啦,晚上估计不能好好刷题了
代码:
#include
#include
#include
#include
using namespace std;
int cmp(const void *c,const void *d)
{
return *(int *)c - *(int *)d ;
}
int flag;
int a[5];
void ...
分类:
其他好文 时间:
2015-07-28 16:05:35
阅读次数:
108
class OwnerImage{public: CSize GetImageSize();private: POINT m_pt[2]; int m_iImgWidth; int m_iImgHeight;}CSize OwnerImage::GetImageSize(){ return...
分类:
编程语言 时间:
2015-07-28 15:59:17
阅读次数:
135
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路:首先想到的机试不断地减去一个数直到0为止,但是这样得复杂度为O(n),只得...
分类:
其他好文 时间:
2015-07-28 15:55:30
阅读次数:
112
示例:if a < 5 { return 0 } else { return 1 } 关于条件语句,需要注意以下几点: ? 条件语句不需要使用括号将条件包含起来(); ? 无论语句体内有几条语句,花括号{}都是必须存在的; ? 左花括号{必须与if或者else处于同一行; ? 在i...
分类:
编程语言 时间:
2015-07-28 14:25:33
阅读次数:
128
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 ...
分类:
其他好文 时间:
2015-07-28 13:12:05
阅读次数:
92
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
For example,
Given:
s1 = "aabcc",
s2 = "dbbca",
When s3 = "aadbbcbcac", return true.
When s3 = "aadbbbaccc", ret...
分类:
其他好文 时间:
2015-07-28 13:09:37
阅读次数:
179
问题描述Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators...
分类:
其他好文 时间:
2015-07-28 12:21:44
阅读次数:
84
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al...
分类:
其他好文 时间:
2015-07-28 12:19:05
阅读次数:
120
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3...
分类:
其他好文 时间:
2015-07-28 10:52:02
阅读次数:
199
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solutio...
分类:
其他好文 时间:
2015-07-28 10:51:19
阅读次数:
108