- 博客(7)
- 收藏
- 关注
原创 70. Climbing Stairs(动态规划题)
DescriptionYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a p...
2018-03-19 19:11:06
178
原创 50.Pow(x, n)(x的n次方)
Description:Implement pow(x, n).Solution:求x的n次方,注意n取值正负0。用这个方法可以让时间复杂度是log(n):pow(x,n)=pow(x,n/2)*pow(x,n/2)自己写的如下,如果输入是x=0.00000001,n=2^31,就会报错,说超时了。class Solution {public: double myPow(double x...
2018-03-19 00:45:29
325
原创 33. Search in Rotated Sorted Array(循环有序数组的搜索)
DescriptionSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If fou...
2018-03-18 22:05:47
147
原创 9. Palindrome Number(回文数)
Description:Determine whether an integer is a palindrome. Do this without extra space.Solution:不用额外的空间判断回文数。这个是我一开始的想法,把数字翻转过来,比较下和原来是否相等。class Solution {public: bool isPalindrome(int x) { ...
2018-03-18 21:06:08
148
原创 7. Reverse Integer(反转整数)
Description:Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing ...
2018-03-18 20:26:09
232
原创 21. Merge Two Sorted Lists(合并有序链表)
Description:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Out...
2018-03-11 22:36:29
143
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人