Sqrt(x)
Easy
Math
Math
Binary Search
Compute and return the integer part of the square root of x.
Constraints
0 ≤ x ≤ 2^31 - 1
Examples
Example 1:
Input: 4
Output: 2
Example 2:
Input: 8
Output: 2
Explanation: √8 = 2.828, integer part is 2
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console