Update Leetcode 题解 - 双指针.md

This commit is contained in:
KunDao 2020-07-09 15:12:40 +08:00 committed by GitHub
parent 1392056d73
commit 1a305f4842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;