摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文
posted @ 2014-11-03 21:20 雄哼哼 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-11-03 21:13 雄哼哼 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321特殊:在32位机中,由于int的范围到该是-20亿到20亿之间,所以如果我们翻转一个数1912345678,就变成876543... 阅读全文
posted @ 2014-11-03 21:10 雄哼哼 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.要求是不能使用额外的空间,言下之意就是不能先转化成字符串来进行处理,所以得想另外一种办法。额外考虑:负数属于回文数字?思路:直接来截取最低位和最高位来进... 阅读全文
posted @ 2014-11-03 21:04 雄哼哼 阅读(88) 评论(0) 推荐(0) 编辑
摘要: The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
posted @ 2014-11-03 20:51 雄哼哼 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 函数调用大家都不陌生,调用者向被调用者传递一些参数,然后执行被调用者的代码,最后被调用者向调用者返回结果,还有大家比较熟悉的一句话,就是函数调用是在栈上发生的,那么在计算机内部到底是如何实现的呢?对于程序,编译器会对其分配一段内存,在逻辑上可以分为代码段,数据段,堆,栈代码段:保存程序文本,指令指针... 阅读全文
posted @ 2014-11-03 20:41 雄哼哼 阅读(1603) 评论(0) 推荐(0) 编辑
摘要: int main(){ char a[6]="hello"; char b[6]="hello"; char* c="hello"; char* d="hello"; //*(c+1)='!';出错 if(a==b) cout<<"1"<<endl;... 阅读全文
posted @ 2014-11-03 20:21 雄哼哼 阅读(254) 评论(0) 推荐(0) 编辑
摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2014-11-03 17:38 雄哼哼 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 图示C内存分配程序代码区存放函数体的二进制代码全局数据区全局变量和静态变量的存储是放在一起的。初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。常量数据存放在另一个区域里。这些数据在程序结束后由系统释放。我们所说的BSS段(bss segment)通常是... 阅读全文
posted @ 2014-11-03 15:25 雄哼哼 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 从网络上看到这样一道有意思的题目,是关于数组与指针的问题,描述如下:main(){ int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d",*(a+1),*(ptr-1));}输出为:2,5请解释以上代码的输出结果。... 阅读全文
posted @ 2014-10-31 15:11 雄哼哼 阅读(772) 评论(0) 推荐(0) 编辑