367 Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False.
Note: Do not use any built-in library function such as sqrt.
Example 1:
Input: 14 Returns: False
Assumming I only have to do this once, I would use a for loop to calculate the square. Otherwise, I would calculate all the perfect squares into a hash table, and use this as my look up table.
// too slow
Last updated