All problems
Perfect Square Check
Problem
Return True if n is a perfect square, meaning it equals some integer multiplied by itself, and False otherwise.
Reuse the integer square root and check whether squaring it recovers n exactly. Negative numbers are never perfect squares.
Hint
Floating point square roots can round incorrectly for large inputs, so use integer arithmetic.
Test cases
case 1
in: [16]
expected: true
case 2
in: [14]
expected: false
case 3
in: [0]
expected: true
case 4
in: [1]
expected: true
case 5
in: [100000000]
expected: true
Starter codePython
def is_perfect_square(n):
# Your code here
pass5 test cases · run your code against them in the editor