一、水是真的水,爽也是真的爽
今天学习内容:《LeetCode零基础指南》(第一讲) 函数_英雄哪里出来的博客-CSDN博客
二、做题记录
三、部分题目解题报告
在此,我们只需要加深对函数的理解,具体的函数体是否符合题目要求我们不在此考虑。
public double myPow(double x, int n) {
return Math.pow(x,n);
}
1. 方法名:myPow.
2.入参: double类型的x 和 int类型的n.
3.方法具体实现Math.pow(x,n);
4.返回值类型为double;
public int mySqrt(int x) {
int left = -1;
int right = x;
if (x == 0 || x == 1) {
return x;
}
while (left + 1 < right) {
int mid = (right + left) / 2;
if ((long) mid * mid <= x) {
left = mid;
} else {
right = mid;
}
}
return left;
}