Description

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator.

Examples

Input:x = 4
Output:2
Explanation:

The square root of 4 is 2.

Input:x = 8
Output:2
Explanation:

The square root of 8 is 2.82842..., rounded down to 2.

Input:x = 1
Output:1
Explanation:

The square root of 1 is 1.

Input:x = 0
Output:0
Explanation:

The square root of 0 is 0.

Constraints

  • 0 ≤ x ≤ 2³¹ - 1

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!