Update Leetcode 题解 - 双指针.md
This commit is contained in:
parent
1392056d73
commit
1a305f4842
@ -78,7 +78,7 @@ Explanation: 1 * 1 + 2 * 2 = 5
|
|||||||
public boolean judgeSquareSum(int target) {
|
public boolean judgeSquareSum(int target) {
|
||||||
if (target < 0) return false;
|
if (target < 0) return false;
|
||||||
int i = 0, j = (int) Math.sqrt(target);
|
int i = 0, j = (int) Math.sqrt(target);
|
||||||
while (i <= j) {
|
while (i <= j) { //只用判断右大于左
|
||||||
int powSum = i * i + j * j;
|
int powSum = i * i + j * j;
|
||||||
if (powSum == target) {
|
if (powSum == target) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user