Algorithm · Uber · Easy
Given a nonnegative integer x, compute its square root and discard any fractional portion. The value you return must also be nonnegative. Implement a function sqrt(x) that takes x as its input and returns the result as an integer. Do not rely on built-in exponentiation operators or functions. For instance, C++ code must not call pow(x, 0.5), and Python code must not use x ** 0.5. Examples Example 1: Input: x = 9 Output: 3 Explanation: Because 9 has an exact square root of 3,…
Checking your access…