摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use... 阅读全文
posted @ 2015-03-18 11:40 hongchun_z 阅读(2545) 评论(0) 推荐(0) 编辑
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan... 阅读全文
posted @ 2015-03-18 10:50 hongchun_z 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A... 阅读全文
posted @ 2015-03-17 18:49 hongchun_z 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.解析: 只有2和5相乘才会出现0,其中整十也可以看做是2和... 阅读全文
posted @ 2015-03-17 18:24 hongchun_z 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet... 阅读全文
posted @ 2015-03-17 16:52 hongchun_z 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:... 阅读全文
posted @ 2015-03-17 16:11 hongchun_z 阅读(124) 评论(0) 推荐(0) 编辑
摘要: //bit_reverse:32位数按位反转函数//作用:把一个32位整数按位反转,即第1位转到第32位,第2位转到第31位,依次下去。//算法实现:第一行代码为奇偶位相互交换;第二行为以两位为一单元,奇偶单元进行交换;第三行为以四位为一单元,奇偶单元进行交换;第四行为以八位为一单元,奇偶单元进行... 阅读全文
posted @ 2015-03-17 15:51 hongchun_z 阅读(143) 评论(0) 推荐(0) 编辑
摘要: C语言 统计整数二进制表示中1的个数(转载)这是一个很有意思的问题,也是在面试中最容易被问到的问题之一。这个问题有个正式的名字叫Hamming_weight,而且wikipedia上也提供了很好的位运算解决的方法,这个下面也会提到。解决这个问题的第一想法是一位一位的观察,判断是否为1,是则计数器加一... 阅读全文
posted @ 2015-03-17 15:01 hongchun_z 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 转载一篇理解堆和栈区别的好文章 此文章是面向C/C++程序员写得。 堆和栈的区别 一、预备知识—程序的内存分配 一个由C/C++编译的程序占用的内存分为以下几个部分 1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其 操作方式类似于数据结构中的栈。 2、堆区(he... 阅读全文
posted @ 2015-03-16 16:04 hongchun_z 阅读(111) 评论(0) 推荐(0) 编辑