dsa · easy

Integer Square Root

Given a non-negative integer x, return the integer square root: the greatest integer r such that r * r <= x. Do not use a built-in exponent that returns a float and then truncates blindly if that would overflow the true floor.

Arguments

Example

x = 82 because 2*2 = 4 <= 8 and 3*3 = 9 > 8.

x = 42.

Constraints

0 <= x <= 2^31 - 1

Examples

Example 1

Input:
4

Expected:
2

Example 2

Input:
8

Expected:
2

Open in the Dojo editor