- 博客(5)
- 收藏
- 关注
原创 Leetcode--50. Pow(x, n)
题目Implement pow(x, n).思路递归的方式,递归关系可以表示为 pow(x,n) = pow(x,n/2)*pow(x,n-n/2),从而将时间复杂的降到O(logn)代码class Solution {public: double myPow(double x, int n) { if(n==0) return 1.0;
2017-08-29 15:27:14 355
原创 Leetcode--338. Counting Bits
题目Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you
2017-08-27 20:50:31 301
原创 Leetcode--655. Print Binary Tree
题目Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. The
2017-08-09 09:47:11 403
原创 Leetcode--Add to List 374. Guess Number Higher or Lower
题目We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I’ll tell you whether the number is higher o
2017-08-02 11:00:13 258
原创 Leetcode--Add to List 371. Sum of Two Integers
题目Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3. 不使用+ - 实现加法思路位运算来实现代码递归版本class Solution {public: int ge
2017-08-02 10:34:12 251
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人