摘要:
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given"25525511135", return["255 阅读全文
posted @ 2017-07-19 18:59
王大咩的图书馆
阅读(411)
评论(0)
推荐(0)
摘要:
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2]have the following unique per 阅读全文
posted @ 2017-07-19 16:30
王大咩的图书馆
阅读(215)
评论(0)
推荐(0)
摘要:
Given a collection of numbers, return all possible permutations. For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3 阅读全文
posted @ 2017-07-19 15:59
王大咩的图书馆
阅读(147)
评论(0)
推荐(0)
摘要:
Implement pow(x, n). 题意:计算x的次方 思路:这题的思路和sqrt的类似,向二分靠近。例如求4^5,我们可以这样求:res=4、4*4^4。就是将每次在res的基础上乘以x本身,换成,每次以x*=x的方式前行,这样时间复杂度为O(logn),代码如下: 把x的n次方划分成两个x 阅读全文
posted @ 2017-07-19 14:46
王大咩的图书馆
阅读(224)
评论(0)
推荐(0)
摘要:
Implementint sqrt(int x). Compute and return the square root of x. 题意:求根号下x 的值 思路:使用二分搜索。先定义x平方根的取值区间,取值区间不同,在一些细节处理上也是不同的。这里去right为(x/2)+1,这是因为一个非负数x 阅读全文
posted @ 2017-07-19 10:48
王大咩的图书馆
阅读(1540)
评论(0)
推荐(0)