这两道题的基本思路和combination那一题是一致的,也是分治的方法。其中combination Sum复杂一点,因为每个数可能用多次。仔细分析下,本质上也是一样的。原来是每个数仅两种可能。现在每个数有k +1中可能,k = target / i。所以就是把简单的if else 分支变成for循...
分类:
其他好文 时间:
2014-09-11 22:15:22
阅读次数:
188
function $$(f) { if (typeof f == 'function') {//f是一个函数 f(); } else { alert('not a function'); } } ...
分类:
编程语言 时间:
2014-09-11 13:51:41
阅读次数:
190
前端时间开发的时候,需要将Ext.data.Store中的data先储存到一个变量中,然后将把这个store的data清空,最后再把变量中的data load到store中。代码是这样的:var tempData = this.store.data.clone();/* Something else...
分类:
其他好文 时间:
2014-09-10 15:32:00
阅读次数:
289
#ifdef DEBUG
#define debug_printf(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define debug_printf(fmt, ...)
#endif
其中##在没有参数的时候去掉前面的","号,否则在没有参数的时候,编译会报错。
#include
#ifdef DEBUG
#define debug_prin...
分类:
编程语言 时间:
2014-09-10 14:17:00
阅读次数:
200
1.先声明javascript函数再使用2.函数生命不应该出现在语句块内,例子如下:if (condition) { function doSomething() { alert(1); }} else { function doSomething() { ...
分类:
其他好文 时间:
2014-09-10 12:09:30
阅读次数:
129
1.字符串包含;var str="我爱中国";if(str.indexOf("中国")>=0){ alert("含有此字符串");}else{ alert("没有此字符串");}2.获取当前url问题;设置或获取对象指定的文件名或路径。window.location.pathname例:http.....
分类:
其他好文 时间:
2014-09-10 12:06:50
阅读次数:
233
4.进程的相关处理system( )给当前进程输入系统shell命令import osif os.name == "nt": command = "dir"else: command = "ls -l" os.system(command) execvp 开始一个新进程, 以取代目前进程 impor...
分类:
编程语言 时间:
2014-09-10 10:46:00
阅读次数:
190
简单,去除所有跟erow有关的代码即可else { if (i % 2 && p.striped) tr.className = 'erow';}if (p.striped) { $('tbody tr:odd', g.bDiv).addClass('erow');}
分类:
其他好文 时间:
2014-09-10 09:32:40
阅读次数:
176
#include
#include
#include
using namespace std;
void print(int n)
{
for(int i=0;(1<<i)<=n;i++)
if(n&(1<<i))
cout<<1;
else cout<<0;
cout<<endl;
}
int main()
{
i...
分类:
其他好文 时间:
2014-09-09 16:03:59
阅读次数:
220
2014年9月9日 11:54:54 1 $a = '-1'; 2 $b = (int)$a; 3 $c = is_numeric($a); 4 if ($a) { 5 echo 1; //echo 1 6 } else { 7 echo 2; 8 } 9 var_dump($b);...
分类:
Web程序 时间:
2014-09-09 15:22:18
阅读次数:
151