leetcode_平方数之和
平方数之和
1 class Solution { 2 public boolean judgeSquareSum(int c) { 3 int i=0; 4 int j=(int)(Math.sqrt(c)); 5 while(i<=j){ 6 if(i*i+j*j==c) return true; 7 else if(i*i+j*j>c){ 8 j--; 9 } 10 else{ 11 i++; 12 } 13 } 14 return false; 15 } 16 }
还是双指针

浙公网安备 33010602011771号