JS字符串本身并不没有提供常用的trim方法,我们可以通过修改String原形来添加此方法,我们就可以直接调用此方法了: String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, '')}String.proto...
分类:
Web程序 时间:
2014-07-01 20:25:50
阅读次数:
242
方法一:产生0~n之间的一个随机数function getRandom(n) {return Math.floor(Math.random() * n);}alert(getRandom(10)); 方法二:产生自定义的Min~Max之间的一个随机数function GetRandomNum(Min...
分类:
Web程序 时间:
2014-07-01 19:34:00
阅读次数:
241
a href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP 点击链接后,页面不动,仅仅打开链接 作用同上,不同浏览器会有差异。点击链接后,不想使页面滚到页首,就用href="javascript:void(0)",不要用href="#",return false也有相似作用具体...
分类:
编程语言 时间:
2014-07-01 13:41:35
阅读次数:
272
First Missing Positive:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] retu...
分类:
其他好文 时间:
2014-07-01 13:13:59
阅读次数:
218
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],...
分类:
其他好文 时间:
2014-07-01 13:01:01
阅读次数:
177
Combinations:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ ...
分类:
其他好文 时间:
2014-07-01 12:58:20
阅读次数:
212
题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,...
分类:
其他好文 时间:
2014-07-01 12:44:09
阅读次数:
199
ll random(ll n){ return (ll)((double)rand()/RAND_MAX*n + 0.5);}ll pow_mod(ll a,ll p,ll n){ if(p == 0) return 1; ll ans = pow_mod(a,p/2...
分类:
其他好文 时间:
2014-07-01 12:29:43
阅读次数:
218
题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For ...
分类:
其他好文 时间:
2014-07-01 12:26:07
阅读次数:
215
def recursive_multiply(x, y, n): if n==1: return x*y else: a = x/pow(10, n/2) b = x-a*pow(10, n/2) c = y/pow(10, n/2) d = y-c*pow(10, n/2) ac = re...
分类:
编程语言 时间:
2014-07-01 12:20:43
阅读次数:
273