Square Root of Integer

Implement int sqrt(int x).

Compute and return the square root of x.

If x is not a perfect square, return floor(sqrt(x))

Example :

Input : 11
Output : 3

DO NOT USE SQRT FUNCTION FROM STANDARD LIBRARY

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Square Root of Integer on Interview Code Editor
Sign Up
to access hints and editorial solutions for Square Root of Integer
Asked In:
  • Facebook
  • Amazon
  • Microsoft
Click here to start solving coding interview questions