1。对于数组A[0,1,2,3,4,...,k],求得0 &array) {
if(array.size() == 0 || array.size() == 1) return -1; if(array.size() == 2) {
return array[1] - array[0];...
分类:
其他好文 时间:
2014-06-10 21:44:16
阅读次数:
401
Given an array of integers, every element
appears twice except for one. Find that single one.Note: Your algorithm should
have a linear runtime complex...
分类:
其他好文 时间:
2014-06-10 21:27:22
阅读次数:
284
其实编程之美也有类似的题,这道题是编程珠玑第二章的题目。题目描述:给定一个字符串,将字符串循环移位K次。最简答的方法就是,通过O(n)的辅助空间,将数组循环移位,时间复杂度就是O(n)但是如果要求空间复杂度为O(1)呢?观察规律可知,对前K位反转以及后面的反转,最后对整个字符串反转就能达到O(1)的...
分类:
其他好文 时间:
2014-06-10 21:02:52
阅读次数:
275
Given two sorted integer arrays A and B, merge
B into A as one sorted array.Note:You may assume that A has enough space (size
that is greater or equal...
分类:
其他好文 时间:
2014-06-10 20:44:02
阅读次数:
298
Given an array of integers, every element
appears three times except for one. Find that single one.Note: Your algorithm
should have a linear runtime c...
分类:
其他好文 时间:
2014-06-10 20:42:48
阅读次数:
315
//正确:if(empty($a))$a=1//错误写法$b = if(empty($a))$a=1
//if前面不能带 等号
分类:
Web程序 时间:
2014-06-10 20:28:29
阅读次数:
221
变量的作用域说明局部变量在函数内部定义的变量,其作用于是所在函数全局变量被定义在所有函数以外的变量,其作用域是整个PHP文件,但在用户自定义的函数内部是不可用的,如果希望在用户自定义函数内部使用全局变量,则要使用global关键字声明全局变量静态变量能够在函数调用结束后仍保留变量值,当再次回到其作用...
分类:
其他好文 时间:
2014-06-10 20:01:43
阅读次数:
339
从开始的时候打开一个页面需要超过9秒的时间到现在可以在3秒内打开,给自己带来了很多欣慰。开始的时候是认为server性能不足,所以讲aliyun服务器从1核升级到了4核,但是发现升级之后和升级之前是一样的效果。既然不是服务器的问题(实际上这样的配置对php网站来说已经比较高端了),而又有那么多大的网...
分类:
其他好文 时间:
2014-06-10 19:50:15
阅读次数:
285
1 class Solution { 2 public: 3 int
singleNumber(int A[], int n) { 4 int bits = sizeof(int)*8; 5 int result=0; 6
for(int i...
分类:
移动开发 时间:
2014-06-10 19:45:48
阅读次数:
334