- 博客(7)
- 收藏
- 关注
转载 leetcode198-House Robber
题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen
2016-08-29 00:26:06 363
原创 Reverse Bits
题目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00
2016-08-27 22:55:50 386
原创 Reverse Integer
题目:Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Test cases had been added to test the overflow behavior. 本题很简单,唯一值得注意的点是反转之后要做溢出检查,有两种方式,一可以每
2016-08-27 15:48:51 381
原创 Factorial Trailing Zeroes
题目: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 乍一看,这确实不难,很简单的做法是先求n!嘛,然后求0的个数。结果是没问题,但是时间复杂度不符合要求,求n!就要O
2016-08-26 23:45:03 373
原创 Majority element
题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority e
2016-08-25 23:15:32 334
转载 C++operator重载问题
operator是C++的关键字,它和运算符一起使用,表示一个运算符函数,理解时应将operator=整体上视为一个函数名。 这是C++扩展运算符功能的方法,虽然样子古怪,但也可以理解:一方面要使运算符的使用方法与其原来一致,另一方面扩展其功能只能通过函数的方式(c++中,“功能”都是由函数实现的)。 一、为什么使用操作符重载? 对于系统的所有操作符,一般情况下,只
2016-08-25 22:38:42 7077 1
转载 Pascal's Triangle帕斯卡三角形算法
题目 Pascal's triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]
2016-08-19 11:19:37 3375
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人