Files
LeetCode-Go/leetcode/0633.Sum-of-Square-Numbers/633. Sum of Square Numbers.go
2020-08-07 17:06:53 +08:00

18 lines
263 B
Go

package leetcode
import "math"
func judgeSquareSum(c int) bool {
low, high := 0, int(math.Sqrt(float64(c)))
for low <= high {
if low*low+high*high < c {
low++
} else if low*low+high*high > c {
high--
} else {
return true
}
}
return false
}