摘要: Permutation Sequence:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3): "123" "132"... 阅读全文
posted @ 2016-03-06 19:38 Lewisr 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Pow(x,n):Implement pow(x, n). 题意:实现pow(x,n)函数。 思路:采用递归的方式,进行计算,注意判断n的值的正负。 代码: public class Solution { public double myPow(double x, int n) { if(n<0){ return 1.0/power(x,-n); ... 阅读全文
posted @ 2016-03-06 19:31 Lewisr 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Sqrt(x):Implement int sqrt(int x).Compute and return the square root of x. 题意:实现开方函数。 思路:采用二分查找的方式进行,判断。 代码: ublic class Solution { public int mySqrt(int x) { if(x>1); if(mid==... 阅读全文
posted @ 2016-03-06 19:28 Lewisr 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Super Ugly Number: Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4... 阅读全文
posted @ 2016-03-06 19:24 Lewisr 阅读(316) 评论(0) 推荐(0) 编辑