Integer Square Root
Return for a non-negative integer , without using a built-in square root.
Requirements
- Binary search on the answer: .
Examples
EXAMPLE WALKTHROUGHperfect square
A guided view of the published example, not a trace of your code.
INPUT
[4]TASKinteger_square_root()
EXPECTED OUTPUT
2Start with the input values shown in this example.
Example 1 of 3
Input: x = 4
Output: 2
Explanation: perfect square
Input: x = 8
Output: 2
Explanation: rounds down
Input: x = 0
Output: 0
Explanation: zero
Hint 1
Find the largest m with m * m <= x.