一切计算机问题,解决方法可以归结为两类:分治和封装。分治是减层,封装是加层。动态规划问题同样可以用这种思路,分治。它可以划分为多个子问题解决,那这样是不是用简单的递归就完成了?也许是的,但是这样会涉及太多的不便的操作。因为子问题有重叠!针对这种子问题有重叠的情况的解决,就是提高效率的关键。所以动态规...
分类:
其他好文 时间:
2014-05-01 10:03:00
阅读次数:
449
Problem 1: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 ...
分类:
其他好文 时间:
2014-05-01 09:43:43
阅读次数:
414
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-05-01 08:35:40
阅读次数:
443
1.1) public class ReturnIt{2) returnType
methodA(byte x, double y){3) return (short)x/y*2;4) }5) }what is valid
returnType for methodA in line 2?这...
分类:
其他好文 时间:
2014-05-01 03:58:57
阅读次数:
330
C语言里的sizeof关键字用于返回变量的类型宽度(变量所占的字节个数)。例如:#include
int main() {int i = 0;int size = sizeof i;printf("size of i is: %d",size);return
0;}会在控制台打印出int类型的变量i...
分类:
其他好文 时间:
2014-05-01 03:29:15
阅读次数:
316
λ演算(Lambda-calculus)是一套用于研究函数定义、应用和递归的形式系统。它由阿兰佐·丘奇(Alonzo
Church)和史蒂芬·科尔·克林(Stephen Cole
Kleene)在20世纪三十年代引入。丘奇运用λ演算在1936年给出“判定性问题”(Entscheidungs prob...
分类:
其他好文 时间:
2014-05-01 03:07:43
阅读次数:
343
<?php
$filename="胡主席好.pdf";
if(!file_exists($filename))
{
echo "不存在此文件";
return;
}
$fp=fopen($filename,"r");
$file_size=filesize($filename);
//配置头文件
/...
分类:
Web程序 时间:
2014-04-29 13:42:20
阅读次数:
356
在项目中有时需要验证用户是否以post方式提交。下面是验证源码:
public boolean checkMethod(String method) {
if (request.getMethod().equalsIgnoreCase(method)) {
return true;
}
else {
...
分类:
Web程序 时间:
2014-04-29 13:34:20
阅读次数:
350
类--类的定义和声明【下】三、关于类定义的更多内容【接上】//P374 习题12.8
class Sales_item
{
public:
double avg_price() const;
bool same_isbn(const Sales_item &rhs) const
{
return rhs.isbn == isbn;
}
Sa...
分类:
编程语言 时间:
2014-04-29 13:28:21
阅读次数:
324
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路同十进制的大数相加。代码如下:
class Solution {
public:
string addBinary(string a, str...
分类:
其他好文 时间:
2014-04-29 13:12:20
阅读次数:
328