Sqrt(x)

Easy · Binary Search · about 10 minutes

Asked at Google, Bloomberg, Amazon, Meta, Microsoft, Apple, Morgan Stanley, Rivian, Arm.

For a non-negative integer x, find the largest integer whose square does not exceed x (the square root with the fractional part dropped). Built-in power and square-root functions are not allowed.

Related guides