dsa · easy

Valid Perfect Square

Return whether the positive integer num is a perfect square: whether some integer k >= 1 satisfies k * k == num. Do not rely on a floating-square-root helper — rounding error on large num will lie.

Example

num = 36. Trying integers: 5*5 = 25 (too small), 6*6 = 36 (exact) → true.

num = 50. 7*7 = 49 and 8*8 = 64. Nothing lands on 50 → false.

num = 1 is 1*1true.

## Arguments - num — positive integer to test for being some k*k

Constraints

1 <= num <= 2^31 - 1

Examples

Example 1

Input:
36

Expected:
true

Example 2

Input:
50

Expected:
false

Example 3

Input:
1

Expected:
true

Open in the Dojo editor