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 }

还是双指针

posted @ 2019-09-22 19:47  chyblogs  阅读(214)  评论(0)    收藏  举报