上一页 1 2 3 4 5 6 7 8 9 ··· 20 下一页
摘要: Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.You may assume each number in the sequ... 阅读全文
posted @ 2015-10-22 03:15 茜茜的技术空间 阅读(225) 评论(0) 推荐(0)
摘要: Implementint sqrt(int x).Compute and return the square root ofx.解题思路:对于一个非负数n,它的平方根不会大于(n/2+1)。在[0, n/2+1]这个范围内可以进行二分搜索(binary search),求出n的平方根。注:在中间过程... 阅读全文
posted @ 2015-10-22 01:16 茜茜的技术空间 阅读(185) 评论(0) 推荐(0)
摘要: Implement pow(x,n).解题思路:pow(x,n)就是求x的n次方。x的N次方可以看做:x^n = x^(n/2)*x^(n/2)*x^(n%2)。所以利用递归求解,当n==1的时候,x^n=x。当然n是可以小于0的,2^(-3) = 1/(2^3)。按照上面那个规律就可以解决了。Ja... 阅读全文
posted @ 2015-10-22 01:01 茜茜的技术空间 阅读(129) 评论(0) 推荐(0)
摘要: Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文
posted @ 2015-10-22 00:47 茜茜的技术空间 阅读(242) 评论(0) 推荐(0)
摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文
posted @ 2015-10-21 02:39 茜茜的技术空间 阅读(135) 评论(0) 推荐(0)
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2015-10-21 02:10 茜茜的技术空间 阅读(306) 评论(0) 推荐(0)
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-10-21 01:38 茜茜的技术空间 阅读(163) 评论(0) 推荐(0)
摘要: Write a program to find then-th ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,1, 2, 3, 4, 5, 6, 8... 阅读全文
posted @ 2015-10-21 01:10 茜茜的技术空间 阅读(575) 评论(0) 推荐(0)
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2015-10-20 13:55 茜茜的技术空间 阅读(126) 评论(0) 推荐(0)
摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-10-20 13:01 茜茜的技术空间 阅读(134) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 20 下一页