Practice Interview Questions
| Question | Status |
|---|---|
Write a function that finds the square root of a given non-negative integer, rounded down to the nearest integer, without using the built-in sqrt() function. For example, the square root of numbers in the range [9, 15] should return 3, and for numbers in the range [16, 24] it should return 4.
Example:
Input: 15
Output: 3
The function should return 3 because: 3^2 = 9, which is less than 15, and 4^2 = 16 exceeds 15.
Constraints:
Write a function that finds the square root of a given non-negative integer, rounded down to the nearest integer, without using the built-in sqrt() function. For example, the square root of numbers in the range [9, 15] should return 3, and for numbers in the range [16, 24] it should return 4.
Example:
Input: 15
Output: 3
The function should return 3 because: 3^2 = 9, which is less than 15, and 4^2 = 16 exceeds 15.
Constraints: