I am solving this question:
Given a positive integer num, write a function that returns True if num is a perfect square else False.
Input: num = 16
Output: true
My solution:
import math
class Solution:
def isPerfectSquare(self, num: int) -> bool:
return type(math.sqrt(16))=='int' //4.0=='int'
I know there are a lot of different solutions which are easier but I want to know how we can get this right as I can't use int
to make it integer as 4.5 will also be the correct answer.