2023-12-09 18:42:21 +08:00
< p > Given a positive integer num, return < code > true< / code > < em > if< / em > < code > num< / code > < em > is a perfect square or< / em > < code > false< / code > < em > otherwise< / em > .< / p >
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
< p > A < strong > perfect square< / strong > is an integer that is the square of an integer. In other words, it is the product of some integer with itself.< / p >
< p > You must not use any built-in library function, such as < code > sqrt< / code > .< / p >
2022-03-27 20:56:26 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
< pre >
< strong > Input:< / strong > num = 16
2022-03-27 20:56:26 +08:00
< strong > Output:< / strong > true
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > We return true because 4 * 4 = 16 and 4 is an integer.
< / pre >
< p > < strong class = "example" > Example 2:< / strong > < / p >
< pre >
< strong > Input:< / strong > num = 14
2022-03-27 20:56:26 +08:00
< strong > Output:< / strong > false
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > We return false because 3.742 * 3.742 = 14 and 3.742 is not an integer.
2022-03-27 20:56:26 +08:00
< / pre >
2023-12-09 18:42:21 +08:00
2022-03-27 20:56:26 +08:00
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
2023-12-09 18:42:21 +08:00
< li > < code > 1 < = num < = 2< sup > 31< / sup > - 1< / code > < / li >
2022-03-27 20:56:26 +08:00
< / ul >