Leetcode
文章平均质量分 57
Gennji61
这个作者很懒,什么都没留下…
展开
-
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 · 157 阅读 · 0 评论 -
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 · 249 阅读 · 0 评论 -
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 · 163 阅读 · 0 评论 -
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 · 158 阅读 · 0 评论 -
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 · 341 阅读 · 0 评论 -
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 · 188 阅读 · 0 评论