LeetCode题解 -- 双指针(633)
Sum of Square Numbers Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2 + b2 = c. 相似题目:LeetCode题解 – 双指针(167) 时间复杂度:O(n) 空间复杂度:O(1) public boolean judgeSquareSum ( int c ) { int hi = ( int ) Math . sqrt ( c ) ; int lo = 0 ; while ( lo <= hi ) { int temp = lo * lo + hi * hi ; if ( temp == c ) { return true ; } else if ( temp > c ) { hi -- ; } else { lo ++ ; } } return false ; } 来源: CSDN 作者: fantow 链接: https://blog.csdn.net/fantow/article/details/104703145