mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 08:27:30 +08:00
18 lines
263 B
Go
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
|
|
}
|