Skip to content

Valid Perfect Square

EasyBinary Search
Decode it first. Clues, constraints, pattern and plan before any code.

Given a positive integer num, return true if it is a perfect square (some whole number times itself) and false otherwise. Do not use a built-in square-root or power function.

num = 16   →  true    (4 * 4)
num = 14   →  false
num = 1    →  true

Constraints

  • 1 <= num <= 2^31 - 1